Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

smartlogic/pg-to-s3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PG to S3

This is a backup script that will dump a postgres database and upload the result to Amazon S3.

Requirements

  • ruby
  • postgres (pg_dump command)
  • aws-sdk gem

Environment variables

export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export BACKUP_BUCKET_NAME="postgres-backup"
export PROJECT_NAME="my-app"
export POSTGRES_USERNAME="postgres"
export POSTGRES_HOST="localhost"
export POSTGRES_PORT="5432"
export POSTGRES_DATABASE="my-app"

.pgpass

A .pgpass file is required for this script as a password cannot be passed in. The format is listed below. It should be only accessible to the user running the script and will be located in the home folder. See the postgress wiki for more information.

hostname:port:database:username:password

Cron

This is the command I used for cron, it sets up the environment for rbenv.

0 0 * * * /bin/bash -c 'PATH=/opt/rbenv/shims:/opt/rbenv/bin:$PATH RBENV_ROOT=/opt/rbenv ruby /home/deploy/pg-to-s3/backup.rb'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages