docker-postgres-backup-local icon indicating copy to clipboard operation
docker-postgres-backup-local copied to clipboard

Secure Backup with a password

Open hoomb opened this issue 3 years ago • 5 comments

It is possible to secure the created "gz" file with a password, so it can be transferred to a cloud backup server or kept in another place?

hoomb avatar Sep 12 '21 16:09 hoomb

You can use schickling/postgres-backup-s3 and upload to a S3 bucket protected using SSE (server-side-encryption) with AWS KMS.

prodrigestivill avatar Oct 28 '21 18:10 prodrigestivill

This is an option but not what I really need. I want to just have a password protected "gzip" file

hoomb avatar Oct 29 '21 05:10 hoomb

Here is an example of that. It would be great to have this feature in this image.

fredericoschardong avatar Apr 06 '22 21:04 fredericoschardong

I'm not sure if it makes sense to add it to this image itself. Since this image does not actually transfer the files and stores only them locally, there is little benefit from encrypting the files — any adversary with access to run the image could also decrypt the files directly.

You can encrypt the files before transferring them to S3 or Google Cloud with a simple script.

GOOGLE_CLOUD_STORAGE_BUCKET="my-bucket-name"

lastDailyBackup="$($find "backups/daily" -type f -printf '%T+ %p\n' | sort -r | head -n 1 | cut -d' ' -f2)"

if [[ ! -f "$lastDailyBackup" ]]; then
    echo "No latest daily backup file found!"
    exit 1
fi

if [[ -n "$BACKUP_ENCRYPTION_KEY" ]]; then
    gpg --batch --yes --passphrase "$BACKUP_ENCRYPTION_KEY" --symmetric "$lastDailyBackup"
    lastDailyBackup="$lastDailyBackup.gpg"
fi

gsutil cp -n "$lastDailyBackup" "gs://$GOOGLE_CLOUD_STORAGE_BUCKET/$dailyFileName"

slhck avatar Jun 30 '22 07:06 slhck

I'm not sure if it makes sense to add it to this image itself. Since this image does not actually transfer the files and stores only them locally, there is little benefit from encrypting the files — any adversary with access to run the image could also decrypt the files directly.

does the decryption/private key have to live on the server? could one not encrypt it using a public key?

this would be a really nice feature (preferably a hardened encryption over simple password protection), there's no reason to have my backups sitting on a server in plain text.

switz avatar Jan 12 '23 21:01 switz