Either run the script as system user `postgres` - who has a corresponding db user with peer authentication set up, according to your `pg_hba.conf` file. Like [@Milen already hinted][1] in his comment. Or set up password-less access for your system user, preferably with a [`.pgpass` file][2]. More details in this closely related answer: https://dba.stackexchange.com/questions/14725/postgresql-scheduled-database-backup/14732#14732. [Or this comprehensive answer about password-less access on SO.][3] [1]: https://dba.stackexchange.com/questions/51342/cant-backup-a-postgres-database-fatal-peer-authentication-failed-for-user-po/51351#comment90942_51342 [2]: http://www.postgresql.org/docs/current/interactive/libpq-pgpass.html [3]: http://stackoverflow.com/questions/15359348/run-batch-file-with-psql-command-without-password/15593100#15593100