You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
521 B

version: '3.8'
services:
db:
image: postgres:latest
restart: unless-stopped
environment:
POSTGRES_PASSWORD: example
POSTGRES_USER: yourusername
POSTGRES_DB: yourdatabase
volumes:
- ./data:/var/lib/postgresql/data
- ./backups:/backups
ports:
- "5432:5432"
command: >
bash -c "while true; do
pg_dumpall -U ${POSTGRES_USER} -f /backups/db_$(date +%Y%m%d%H%M%S).sql;
gzip /backups/db_$(date +%Y%m%d%H%M%S).sql;
sleep 24h;
done"