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.
Top comments (1)
Thanks for the tips, so basically it's no difference than normal backups without containers, except we have to execute the commands into the container with
docker attach {containerid}