Skip to content

Commit

Permalink
Add AWS_S3_STORAGE_CLASS option
Browse files Browse the repository at this point in the history
  • Loading branch information
th0th committed Jan 14, 2024
1 parent 3bba297 commit 21d6fab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@

### Environment variables

| Variable | Required | Default value | Description |
|-----------------------|:--------:|----------------|-------------------------------------------------------------------------|
| AWS_ACCESS_KEY_ID || | Access key id for the AWS account |
| AWS_REGION || | Region for the AWS bucket |
| AWS_S3_ENDPOINT || | AWS S3 endpoint with bucket and path (e.g. "my-bucket/postgres-backup") |
| AWS_SECRET_ACCESS_KEY || | Secret access key for the AWS account |
| POSTGRES_DB || | Postgres server database |
| POSTGRES_HOST | | postgres | Postgres server host |
| POSTGRES_PASSWORD || | Postgres server password |
| POSTGRES_PORT | | 5432 | Postgres server port |
| POSTGRES_USER | | postgres | Postgres server user |
| POSTGRES_VERSION | | 15 | Postgres server version (12, 13, 14 or 15) |
| WEBGAZER_PULSE_URL | | | [WebGazer Pulse](https://www.webgazer.io/pulse) URL |
| Variable | Required | Default value | Description |
|-----------------------|:--------:|---------------|-------------------------------------------------------------------------------------------------------------------------------|
| AWS_ACCESS_KEY_ID || | Access key id for the AWS account |
| AWS_REGION || | Region for the AWS bucket |
| AWS_S3_ENDPOINT || | AWS S3 endpoint with bucket and path (e.g. "my-bucket/postgres-backup") |
| AWS_S3_STORAGE_CLASS | | STANDARD_IA | AWS S3 storage class (see https://aws.amazon.com/s3/storage-classes/ and https://rclone.org/s3/#s3-storage-class for options. |
| AWS_SECRET_ACCESS_KEY || | Secret access key for the AWS account |
| POSTGRES_DB || | Postgres server database |
| POSTGRES_HOST | | postgres | Postgres server host |
| POSTGRES_PASSWORD || | Postgres server password |
| POSTGRES_PORT | | 5432 | Postgres server port |
| POSTGRES_USER | | postgres | Postgres server user |
| POSTGRES_VERSION | | 15 | Postgres server version (12, 13, 14 or 15) |
| WEBGAZER_PULSE_URL | | | [WebGazer Pulse](https://www.webgazer.io/pulse) URL |

### Running

Expand All @@ -33,6 +34,7 @@
-e POSTGRES_VERSION=<postgres_version[15]> \
-e AWS_ACCESS_KEY_ID=<aws_access_key_id> \
-e AWS_SECRET_ACCESS_KEY=<aws_secret_access_key> \
-e AWS_S3_STORAGE_CLASS=<aws_s3_storage_class[STANDARD_IA]> \
-e AWS_S3_ENDPOINT=<aws_s3_endpoint> \
-e WEBGAZER_PULSE_URL=<webgazer_pulse_url>

Expand All @@ -48,6 +50,7 @@
-e AWS_ACCESS_KEY_ID=g9XqNnqKmUk6xqwkStkN \
-e AWS_SECRET_ACCESS_KEY=GLBZ8mQf27UL57YHbkLhXWtfJWVwtUBbQup6mFzw \
-e AWS_S3_ENDPOINT=my-bucket/postgres-backup \
-e AWS_S3_STORAGE_CLASS=GLACIER \
-e WEBGAZER_PULSE_URL=https://pulse.webgazer.io/1-8f713c75d659

## Shameless plug
Expand All @@ -58,17 +61,20 @@ I am an indie hacker, and I am running two services that might be useful for you

[<img alt="WebGazer" src="https://user-images.githubusercontent.com/698079/162474223-f7e819c4-4421-4715-b8a2-819583550036.png" width="256" />](https://www.webgazer.io/?utm_source=github&utm_campaign=postgres-s3-backup-readme)

[WebGazer](https://www.webgazer.io/?utm_source=github&utm_campaign=postgres-s3-backup-readme) is a monitoring service that checks your website, cron jobs, or scheduled tasks on a regular basis. It notifies
[WebGazer](https://www.webgazer.io/?utm_source=github&utm_campaign=postgres-s3-backup-readme) is a monitoring service
that checks your website, cron jobs, or scheduled tasks on a regular basis. It notifies
you with instant alerts in case of a problem. That way, you have peace of mind about the status of your service without
manually checking it.

### PoeticMetric

[<img alt="PoeticMetric" src="https://user-images.githubusercontent.com/698079/162474946-7c4565ba-5097-4a42-8821-d087e6f56a5d.png" width="256" />](https://www.poeticmetric.com/?utm_source=github&utm_campaign=postgres-s3-backup-readme)

[PoeticMetric](https://www.poeticmetric.com/?utm_source=github&utm_campaign=postgres-s3-backup-readme) is a privacy-first, regulation-compliant, blazingly fast analytics tool.
[PoeticMetric](https://www.poeticmetric.com/?utm_source=github&utm_campaign=postgres-s3-backup-readme) is a
privacy-first, regulation-compliant, blazingly fast analytics tool.

No cookies or personal data collection. So you don't have to worry about cookie banners or GDPR, CCPA, and PECR compliance.
No cookies or personal data collection. So you don't have to worry about cookie banners or GDPR, CCPA, and PECR
compliance.

## License

Expand Down
3 changes: 2 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SECONDS=0
: "${POSTGRES_PASSWORD:?Please set the environment variable.}"

# optional environment variables with defaults
AWS_S3_STORAGE_CLASS="${AWS_S3_STORAGE_CLASS:-STANDARD_IA}"
POSTGRES_HOST="${POSTGRES_HOST:-postgres}"
POSTGRES_PORT="${POSTGRES_PORT:-5432}"
POSTGRES_USER="${POSTGRES_USER:-postgres}"
Expand Down Expand Up @@ -43,7 +44,7 @@ echo "Uploading to S3..."
rclone copyto \
--s3-no-check-bucket \
"./${BACKUP_FILE_NAME}" \
":s3,access_key_id=${AWS_ACCESS_KEY_ID},provider=AWS,region=${AWS_REGION},secret_access_key=${AWS_SECRET_ACCESS_KEY},storage_class=GLACIER:${AWS_S3_ENDPOINT}/${BACKUP_FILE_NAME}"
":s3,access_key_id=${AWS_ACCESS_KEY_ID},provider=AWS,region=${AWS_REGION},secret_access_key=${AWS_SECRET_ACCESS_KEY},storage_class=${AWS_S#AWS_S3_STORAGE_CLASS}:${AWS_S3_ENDPOINT}/${BACKUP_FILE_NAME}"
echo "Uploading to S3... Done."

if [ -n "${WEBGAZER_PULSE_URL}" ]; then
Expand Down

0 comments on commit 21d6fab

Please sign in to comment.