Skip to content
This repository has been archived by the owner on Aug 9, 2018. It is now read-only.

koudaiii-archives/pgdump-to-s3-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

pgdump-to-s3-go

Build Status Docker Repository on Quay GitHub release

Description

pgdump-to-s3-go create pg_dump, put dump file in the specified s3 URL. Also change the file name and put it in s3 URL where all the past dump files are stored (ex: <backet_name>/<prefix_name>s/<file_name>.YYYYMMDD_HHMMSS)

Table of Contents

Requirements

  • pg_dump command
  • You need to set AWS credentials beforehand, or you can also use named profile written in ~/.aws/credentials.
export AWS_ACCESS_KEY_ID=XXXXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXXXX
# or configure them in ~/.aws/credentials

export AWS_REGION=xx-yyyy-0

Installation

Using Homebrew (OS X only)

Formula is available at koudaiii/homebrew-tools.

$ brew tap koudaiii/pgdump-to-s3-go
$ brew install pgdump-to-s3-go

Precompiled binary

Precompiled binaries for Windows, OS X, Linux are available at Releases.

From source

To install, use go get:

$ go get -d github.com/koudaiii/pgdump-to-s3-go
$ cd $GOPATH/src/github.com/koudaiii/pgdump-to-s3-go
$ make deps
$ make install

Run in a Docker container

docker image is available at quay.io/koudaiii/pgdump-to-s3-go.

# -t is required to colorize logs
$ docker run \
    --rm \
    -t \
    -e AWS_ACCESS_KEY_ID=XXXXXXXX \
    -e AWS_SECRET_ACCESS_KEY=XXXXXXXX \
    -e AWS_REGION=xx-yyyy-0 \
    quay.io/koudaiii/pgdump-to-s3-go:latest \
    --db-url=postgresq://hoge:hoge@hoge:5432/dbname \
    --s3-url=s3://hogehoge/dump/db.dump \
    --dry-run

Usage

pgdump-to-s3-go --db-url=postgresq://hoge:hoge@hoge:5432/dbname --output s3://hogehoge/dump/db.dump

Uploaded!
  s3://hogehoge/dump/db.dump
  s3://hogehoge/dumps/db.dump.20180204_231110
  • --dry-run
pgdump-to-s3-go --db-url=postgresq://hoge:hoge@hoge:5432/dbname --output s3://hogehoge/dump/db.dump --dry-run

Upload URL
  s3://hogehoge/dump/db.dump
  s3://hogehoge/dumps/db.dump.20180204_231110

Options

Option Description Required Default
--help Print command line usage
-v, --version Print version

Development

Clone this repository and build using make.

$ go get -d github.com/koudaiii/pgdump-to-s3-go
$ cd $GOPATH/src/github.com/koudaiii/pgdump-to-s3-go
$ make

Contribution

  1. Fork (https://github.com/koudaiii/pgdump-to-s3-go/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create a new Pull Request

Author

koudaiii

License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published