postgres-backup
A tiny and simple Docker image for backing up Postgresql.
20181204-20190220: Pg_dump and pg_dumpall from Postgresql 11.1, Apline Edge.
Environment variables
pre-set runtime variables
- VAR_LINUX_USER (postgres): The Linux/Postgresql user that performs the backup.
- VAR_FINAL_COMMAND (/usr/sbin/crond -f -d 8): Backups are initiated by crond.
- VAR_BACKUP_DIR (/backup): Where the backups will be created.
- VAR_PORT (5432): Database port.
- VAR_FORMAT (custom): Pg_dump format.
- VAR_JOBS (1): Number of parallel backup jobs. Only used if VAR_FORMAT="directory".
- VAR_COMPRESS (9): 0 is no compression, 9 is max compression. For directory and plain formats only.
- VAR_DUMP_GLOBALS (yes): Dump all postgres globals in a separate file.
- VAR_DELETE_DUPLICATES (yes): Duplicate files will be deleted from previous backup.
Other runtime variables
- VAR_HOST: The database host.
- VAR_DATABASES: Comma separated list of databases to back up.
- VAR_<database from VAR_DATABASES>_format: Like VAR_FORMAT, but limited to named database.
- VAR_<database from VAR_DATABASES>_jobs: Like VAR_JOBS, but limited to named database.
- VAR_CLEAN: Set to "yes" to add cleaning commands to the backup.
- VAR_<database from VAR_DATABASES>_clean: Like VAR_CLEAN, but limited to named database.
- VAR_SCHEMA_ONLY: Set to "yes" to only dump schemas.
- VAR_<database from VAR_DATABASES>_excludeschemas: Schemas in named database that should not be backed up.
- VAR_<database from VAR_DATABASES>_schemas: Limit back up to these schemas in named database.
- VAR_<database from VAR_DATABASES>_excludetables: Tables in named database that should not be backed up.
- VAR_<database from VAR_DATABASES>_tables: Limit back up to these tables in named database.
- VAR_BLOBS: Set to "no" to not back up data blobs.
- VAR_<name>: Name of backup cron job.
- VAR_cron_<name>: When to run backups of named job.
Cron examples
VAR_weekdays="/bin/date +%a"
VAR_cron_weekdays="0 21 * * 1-5"
VAR_weekly="(( $(/bin/date +%d) + 6 ) / 7)"
VAR_cron_weekly="0 19 * * 5"
VAR_monthly="/bin/date +%b"
VAR_cron_monthly="0 17 1 * *"
Capabilities
Can drop all but SETPCAP, SETGID and SETUID.