1. 指定服务器,
  2. 定时执行

​https://cloud.tencent.com/developer/article/1185186​​​​http://wzktravel.github.io/2016/08/23/How-to-pass-in-password-to-pg-dump/​

配置​​.pg_pass​​ 就可以不用输入密码

vi ~/.pg_pass

chmod 600 ~/.pg_pass

hostname:port:database:username:password
# bash
pg_dump -d dbname -h 172.20.1.1 -p 5432 -U username > /backups/dbname.bak

定时任务cron

crontab -e

0 * * * 0 pg_dump -U postgres dbname > ~/postgres/backups/dbname.bak

懂得,原来世界如此简单!