Skip to content

Postgres utility container to dump a database and push to S3 :) Lovely

License

Notifications You must be signed in to change notification settings

osodevops/docker-pg-dumper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

docker-pg-dump

Postgres utility container to dump a database and push to S3 :) Lovely

Usage example

In Kubernetes you can setup backups with:

  jobTemplate:
    spec:
      backoffLimit: 0 # pod will not attempt retry on failure
      activeDeadlineSeconds: 3300 # 55min once a Job reaches activeDeadlineSeconds, all of its running Pods are terminated
      template:
        spec:
          serviceAccountName: pg-dumper
          containers:
          - name: pg-dumper
            image: osodevops/docker-pg-dumper:v1.0.3
            command: ["/bin/sh", "-c"]
            args:
            - |
              DATABASE_PREFIX=$(date +"%y_%m_%d");
              cd /root && PGPASSWORD=$DB_PASSWORD pg_dump -F plain -v -O -o -U $DB_USERNAME -h $DB_HOST -d ${DATABASE_NAME} -f ${DATABASE_PREFIX}_${DATABASE_NAME}.sql;
              gzip ${DATABASE_PREFIX}_${DATABASE_NAME}.sql;
              aws s3 cp /root/${DATABASE_PREFIX}_${DATABASE_NAME}.sql.gz s3://${AWS_ACCOUNT}-rds-data-backups/;
            imagePullPolicy: IfNotPresent # | IfNotPresent | Always

About

Postgres utility container to dump a database and push to S3 :) Lovely

Resources

License

Stars

Watchers

Forks

Packages

No packages published