Install pgAgent:
sudo apt install pgagent
In pgAdmin add extension:
CREATE EXTENSION pgagent;
Create file .pgpass in your user folder with:
YourHost:YourPort:YourBase:YourUser:YourPassword
For example: *:5432:test_base:bak_user:123
Then restrict access to it:
chmod 600 .pgpass
Add your DataBase user to pg_hba.conf
Restart postgres service:
sudo service postgresql restart
Add pgAgent as a daemon on your server:
pgagent host=/var/run/postgresql dbname=test_base user=bak_user
For some reason, pgAgent Jobs is appeared only if you create a connection where the Maintenance database is the database to be backed up. If you know how to fix this please let me know in the comments.
Code that would be executed on schedule:
pg_dump --username=bak_user --dbname=test_base --clean --file=/home/user/backup-`date +%d-%m-%Y-%H-%M-%S`.sql
midnight commander (not necessary) :
sudo apt install mc
Негізгі бет Scheduled PostgreSQL backups using pgAdmin and pgAgent
No video
Пікірлер: 5