How would you go about taking automatic rotated backups of a postgresql database running inside a docker 1.3 container? I'm mostly interested in the overall approach vs. the details of actual the backup commands themselves.
I am thinking about updating this autobackup script, which has apparently been around since 2005. My current plan is
- Install the script in cron.daily on the docker host
- Have the script use direct local filesystem access for the rotation logic to handle the existence tests,
mkdir
andrm
commands - use
docker exec containername
to run thepsql
andpg_dump
commands within the container, probably sending the stdout content to the docker host filesystem in the correct place via shell redirection
The autobackup script is nice but don't verget to make a backup of the users and passwords: pd_dumpall -g If you don't need seperate backups of each database inside postgresql, it's eysier to use pg_dumpall.