定期在Docker Compose中使用cron备份Postgres数据库

我想定期备份一个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

我已阅读本教程,但我不知道如何正确整合它。 任何帮助?