Auto backup of Databases in Postgres Container.

umeshdhakar

Umesh Kumar Dhakar

Posted on September 10, 2018

Auto backup of Databases in Postgres Container.

1. Create A file in Container.
touch /path/<file>
(ex. touch /data/bkp_cmd.sh)

2. Write Backup command to that file.
echo "pg_dumpall -U postgres -f /path/file" >> <file>
(ex. eg. echo "pg_dumpall -U postgres -f
/data/files/backup_date +%Y%m%d.sql" >> bkp_cmd.sh )

3. Make file executable.
chmod 777 <file>
(ex. chmod 777 /data/bkp_cmd.sh )

4. Append cron file.
crontab -e
00 00 */15 * * /data/bkp_cmd.sh >> /data/logs/cron_logs.txt 2>&1
You can generate cron command here.
if no editor is installed then
Append command to cron file via
(crontab -l && echo "00 00 */15 * * /data/bkp_cmd.sh >> /data/backup_cron_logs.txt 2>&1") | crontab -

5. Check whether cron service is running or not.
service cron status
If it it is not running, start it by command
service cron start

5. Wait and check the backup file at specified time.

Thanks for reading! 😊
Please leave a comment if you have any suggestions or you have any doubt.

💖 💪 🙅 🚩
umeshdhakar
Umesh Kumar Dhakar

Posted on September 10, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related