Created
June 13, 2025 14:59
-
-
Save jamessimas/a1e7d2f8bc611e43565fe2931e46b405 to your computer and use it in GitHub Desktop.
Backup script for external hard drives
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
| bkexternal () { | |
| HOST=$(hostname -s) | |
| EXT_DRIVE_PATH="/Volumes/RsyncBackupDrive" | |
| if [[ ! -e "$EXT_DRIVE_PATH" ]]; then | |
| echo "Drive path not found: $EXT_DRIVE_PATH" | |
| return 1 | |
| fi | |
| # Helpful cheat sheet: https://devhints.io/rsync | |
| rsync -avz --delete --delete-excluded \ | |
| --exclude 'Applications' \ | |
| --exclude '.DS_Store' \ | |
| --exclude '.Trash' \ | |
| --exclude 'Library' \ | |
| "$HOME/" \ | |
| "$EXT_DRIVE_PATH/backup-$HOST" | |
| local return_code=$? | |
| if [[ $return_code -ne 0 ]]; then | |
| return 1 | |
| fi | |
| date > "$EXT_DRIVE_PATH/backup-$HOST-last-backup.txt" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment