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
1.9 KiB

5 years ago
  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. depends_on:
  18. - postgres
  19. links:
  20. - postgres
  21. environment:
  22. SCHEDULE: '@daily'
  23. S3_REGION: region
  24. S3_ACCESS_KEY_ID: key
  25. S3_SECRET_ACCESS_KEY: secret
  26. S3_BUCKET: my-bucket
  27. S3_PREFIX: backup
  28. POSTGRES_BACKUP_ALL: "false"
  29. POSTGRES_HOST: host
  30. POSTGRES_DATABASE: dbname
  31. POSTGRES_USER: user
  32. POSTGRES_PASSWORD: password
  33. POSTGRES_EXTRA_OPTS: '--schema=public --blobs'
  34. ```
  35. ### Automatic Periodic Backups
  36. You can additionally set the `SCHEDULE` environment variable like `-e SCHEDULE="@daily"` to run the backup automatically.
  37. More information about the scheduling can be found [here](http://godoc.org/github.com/robfig/cron#hdr-Predefined_schedules).
  38. ### Backup All Databases
  39. You can backup all available databases by setting `POSTGRES_BACKUP_ALL="true"`.
  40. Single archive with the name `all_<timestamp>.sql.gz` will be uploaded to S3
  41. ### Endpoints for S3
  42. An Endpoint is the URL of the entry point for an AWS web service or S3 Compitable Storage Provider.
  43. You can specify an alternate endpoint by setting `S3_ENDPOINT` environment variable like `protocol://endpoint`
  44. **Note:** S3 Compitable Storage Provider requires `S3_ENDPOINT` environment variable
  45. ### Encryption
  46. You can additionally set the `ENCRYPTION_PASSWORD` environment variable like `-e ENCRYPTION_PASSWORD="superstrongpassword"` to encrypt the backup. It can be decrypted using `openssl aes-256-cbc -d -in backup.sql.gz.enc -out backup.sql.gz`.