How Do I Backup My PostgreSQL Database with Cron?

后端 未结 8 1167
孤街浪徒
孤街浪徒 2021-01-30 09:31

I can run commands like vacuumdb, pg_dump, and psql just fine in a script if I preface them like so:

/usr/bin/sudo -u postgres /usr/bin/pg_dump -Fc mydatabase &g         


        
相关标签:
8条回答
  • 2021-01-30 10:26

    you probably have "ident" authentication in your pg_hba.conf for your postgres user. The option "-u postgres" fails when that is the case. either change user to postgres in your backup script or configure a different authentication method.

    0 讨论(0)
  • 2021-01-30 10:32

    Your environment variable are maybe not set in cron.

    In your normal session, you probably have defined these variables:

    PG_PORT
    PG_HOST
    PG_DATABASE
    PG_USERNAME
    PG_PASSWORD
    

    Add an "env" into yout script.

    0 讨论(0)
提交回复
热议问题