does someone want to review our backup to backblaze script courtesy of ClaudeAI? seems to work!
#!/bin/bash BACKUP_DIR="backup" BUCKET_NAME="" DATE=$(date +%Y%m%d) BACKUP_FILE="$DATE-akkoma.pgdump" ENCRYPTED_FILE="${BACKUP_FILE}.enc" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" export B2_APPLICATION_KEY_ID="" export B2_APPLICATION_KEY="" # Your encryption key - store this securely! ENCRYPTION_KEY="" # Stop docker compose docker compose down akkoma # Create backup docker compose exec db pg_dump -d akkoma --format=custom -f /backup/$BACKUP_FILE # Start docker compose again docker compose up akkoma # Encrypt the backup openssl enc -aes-256-cbc -salt -in "./$BACKUP_DIR/$BACKUP_FILE" -out "./$BACKUP_DIR/$ENCRYPTED_FILE" -k "$ENCRYPTION_KEY" -pbkdf2 # Upload encrypted file to B2 if $SCRIPT_DIR/venv/bin/b2 file upload $BUCKET_NAME "./$BACKUP_DIR/$ENCRYPTED_FILE" "backups/$ENCRYPTED_FILE"; then # Delete local files only if upload was successful rm "./$BACKUP_DIR/$BACKUP_FILE" "./$BACKUP_DIR/$ENCRYPTED_FILE" echo "Backup completed, encrypted, and uploaded successfully" else echo "Upload failed - keeping local backup files" exit 1 fiConversation
Notices
-
Embed this notice
kaia (kaia@brotka.st)'s status on Saturday, 30-Nov-2024 23:17:27 JST kaia -
Embed this notice
Anton (antondollmaier@mastodon.social)'s status on Saturday, 30-Nov-2024 23:32:41 JST Anton @kaia suggestion: use restic: https://restic.readthedocs.io/en/stable/
It can upload to b2 natively, is a single go binary, and the pg_dump command can be called directly, thus you'd end up with a single command for the backup. Encryption is also handled natively, so no additional openssl required.
I'd need to verify the exact command, don't have it out of my head.
The script itself looks good to me.kaia likes this. -
Embed this notice
kaia (kaia@brotka.st)'s status on Saturday, 30-Nov-2024 23:34:09 JST kaia @antondollmaier thanks, checking out! :kaia_loo]
-
Embed this notice