I would like to periodically backup a Postgres database. I am using Docker Compose, here is the snippet of the postgres container:
postgres: build: ./compose/postgres volumes: - postgres_data:/var/lib/postgresql/data - postgres_backup:/backups
And the Postgres dockerfile:
FROM postgres:9.6 # add backup scripts ADD backup.sh /usr/local/bin/backup ADD restore.sh /usr/local/bin/restore ADD list-backups.sh /usr/local/bin/list-backups # make them executable RUN chmod +x /usr/local/bin/restore RUN chmod +x /usr/local/bin/list-backups RUN chmod +x /usr/local/bin/backup
I would like to add a cron task (say
backup-cron) that runs
backup.sh every day at midnight. I have read this tutorial but I do not know how to properly integrate it. Any help?