Created
June 17, 2023 20:52
-
-
Save lordjabez/415b3953c0cb3c45ad069af4c33d9032 to your computer and use it in GitHub Desktop.
Compress, encrypt, and backup a folder to S3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
current_date=$(date "+%Y%m%d") | |
bucket_name="my-backup-bucket" | |
backup_filename="/tmp/documents-backup-${current_date}.tgz" | |
export AWS_PROFILE=backup | |
aws-refresh-credentials | |
aws s3 cp "${backup_filename}.gpg" "s3://${bucket_name}/documents/" | |
rm "${backup_filename}" "${backup_filename}.gpg" | |
rm -rf Notes/* | |
cp -R "$HOME/Library/Group Containers/group.com.apple.notes" Notes/ | |
current_date=$(date "+%Y%m%d") | |
backup_filename="/tmp/documents-backup-${current_date}.tgz" | |
encrypted_filename="${backup_filename}.gpg" | |
tar czvf "${backup_filename}" * | |
gpg -c --cipher-algo AES256 "${backup_filename}" | |
rm "${backup_filename}" | |
split -b 2g "${encrypted_filename}" "${encrypted_filename}." | |
rm "${encrypted_filename}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment