linux postgresql 定时备份
1.备份脚本:
/usr/pgsql-10/bin/pg_dump -U postgres -h 127.0.0.1 -p 5432 -f /data/sql_bak/fame_$(date +%Y%m%d_%H_%M_%S).sql fame
-u 用户名
-h ip
-p 端口号
-f 备份文件路径
fame(这儿表示数据库的名字,fame是我的数据库的名字)
脚本命名为: sql_bak.sh
上传脚本到linux服务器,如图:
2. 添加定时任务, 测试的时候设置 每一分钟执行一次,如图:
*/1 * * * * /data/sql_bak/sql_bak.sh