You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.4 KiB

  1. # postgres-backup-s3
  2. Backup PostgresSQL to S3 (supports periodic backups)
  3. ## Usage
  4. Docker:
  5. ```sh
  6. $ docker run -e S3_ACCESS_KEY_ID=key -e S3_SECRET_ACCESS_KEY=secret -e S3_BUCKET=my-bucket -e S3_PREFIX=backup -e POSTGRES_DATABASE=dbname -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -e POSTGRES_HOST=localhost schickling/postgres-backup-s3
  7. ```
  8. Docker Compose:
  9. ```yaml
  10. postgres:
  11. image: postgres
  12. environment:
  13. POSTGRES_USER: user
  14. POSTGRES_PASSWORD: password
  15. pgbackups3:
  16. image: schickling/postgres-backup-s3
  17. links:
  18. - postgres
  19. environment:
  20. SCHEDULE: '@daily'
  21. S3_REGION: region
  22. S3_ACCESS_KEY_ID: key
  23. S3_SECRET_ACCESS_KEY: secret
  24. S3_BUCKET: my-bucket
  25. S3_PREFIX: backup
  26. POSTGRES_DATABASES: dbname
  27. POSTGRES_USER: user
  28. POSTGRES_PASSWORD: password
  29. POSTGRES_EXTRA_OPTS: '--schema=public --blobs'
  30. ```
  31. ## Environment variables
  32. - `POSTGRES_EXTRA_OPTS` pg_dump options (default: '')
  33. - `POSTGRES_DATABASES` list of databases you want to backup *required*
  34. - `POSTGRES_HOST` the postgres host *required*
  35. - `POSTGRES_PORT` the postgres port (default: 5432)
  36. - `POSTGRES_USER` the postgres user *required*
  37. - `POSTGRES_PASSWORD` the mysql password *required*
  38. - `POSTGRES_PASSWORD_FILE` path to file containing the postgres password; alternative to `POSTGRES_PASSWORD`
  39. - `S3_ACCESS_KEY_ID` your AWS access key *required*
  40. - `S3_ACCESS_KEY_ID_FILE` path to file containing your AWS access key; alternative to `S3_ACCESS_KEY_ID`
  41. - `S3_SECRET_ACCESS_KEY` your AWS secret key *required*
  42. - `S3_SECRET_ACCESS_KEY_FILE` path to file containing your AWS secret key; alternative to `S3_SECRET_ACCESS_KEYs`
  43. - `S3_BUCKET` your AWS S3 bucket path *required*
  44. - `S3_PREFIX` path prefix in your bucket (default: 'backup')
  45. - `S3_FILENAME` a consistent filename to overwrite with your backup. If not set will use a timestamp.
  46. - `S3_REGION` the AWS S3 bucket region (default: us-west-1)
  47. - `S3_ENDPOINT` the AWS Endpoint URL, for S3 Compliant APIs such as [minio](https://minio.io) (default: none)
  48. - `S3_S3V4` set to `yes` to enable AWS Signature Version 4, required for [minio](https://minio.io) servers (default: no)
  49. - `SCHEDULE` backup schedule time, see explainatons below
  50. ### Automatic Periodic Backups
  51. You can additionally set the `SCHEDULE` environment variable like `-e SCHEDULE="@daily"` to run the backup automatically.
  52. More information about the scheduling can be found [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules).