Public Repository

Last pushed: 5 months ago
Short Description
A docker image that backups using pg_dumpall and then uploads the backups to S3
Full Description

Backup Container

This container serves to backup the postgres server.

Backup Method

This set of backup scripts runs pg_dumpall against the database cluster and dumps all databases and metadata. Backups are gzip'ed and split into chunks using split

Backup Destination

Backups are uploaded to Amazon S3 at s3://labsentry-acc-db-backup/ for the acceptance environment.

Restoring backups

backups should be restored to a clean/empty postgres server and can be restored using this command:
cat FILENAME.gz* | gunzip | psql -h hostname -p port -U user -d any_valid_database -f FileName

Backup Schedule

The backups run at 07:05 UTC once per day Tuesday-Sunday. The backup file will be named BACKUPNAME{DAY_OF_WEEK}. This will overwrite in S3 after 1 week.

On Monday it creates a weekly backup where the name is BACKUP_NAMEWK{X} where X is a number between 0 and 4 - this keeps the last 5 weeks and overwrites them. (it calculates this using WeekNumber % 5 for those curious)

On the first of the month it creates a monthly backup named BACKUPNAME{MonthYear} Since these will always be unique, the monthly backups do not overwrite.

Only 1 backup will be done for each given day, if it is the 1st of the month then the daily and weekly will be skipped. If it is a monday then the daily will be skipped on the backup will just have the week number.

The image is configured using these environment variables at run time.

BACKUP_NAME = base file name e.g. LabSentry-Acc

S3_BACKUP_ACCESS_KEY
S3_BACKUP_SECRET_KEY

S3_BACKUP_URL e.g. s3://some-bucket-name/some-folder-path/

Postgress connection info:
POSTGRES_HOST
POSTGRES_DB
POSTGRES_USER
POSTGRES_PASSWORD

Jobs can be tested inside the container using alternate times if you use the faketime library (example below)

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 FAKETIME="2017-3-13 7:05:00" ./backup_daily.sh

TODO

This project should be opensourced and made freely available removing and LabSentry speicifc info (mostly this readme)

Docker Pull Command
Owner
angelosartobjt

Comments (0)