我想定期备份Postgres数据库。我正在使用Docker Compose,这是Postgres容器的片段:
postgres:
build: ./compose/postgres
volumes:
- postgres_data:/var/lib/postgresql/data
- postgres_backup:/backups
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
我想添加一个cron任务(比如说backup-cron
),每天午夜运行backup.sh
。
我已阅读此tutorial但我不知道如何正确整合它。有什么帮助吗?