Last active
July 7, 2018 11:36
-
-
Save adrianchifor/5d008000ec9ae56f9269ec89c2ffe496 to your computer and use it in GitHub Desktop.
Mac encrypted backup
This file contains 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 | |
if [ ! $(which 7za) ]; then echo "Install 7z: brew install p7zip"; return 1; fi | |
BACKUP_NAME="macbook-pro-home-backup.7z" | |
USER=$(whoami) | |
BACKUP_PATHS=( | |
"/Users/$USER/Google Drive/Backup/" | |
) | |
echo "Preparing backup of /Users/$USER..." | |
7za a -p -mhe=on /tmp/$BACKUP_NAME /Users/$USER "-xr!.cache" "-xr!.Trash" "-xr!Library" "-xr!$BACKUP_NAME" | |
if [ ! -s /tmp/$BACKUP_NAME ]; then | |
echo "Backup failed, exiting." | |
rm -f /tmp/$BACKUP_NAME | |
return 1 | |
fi | |
for path in "${BACKUP_PATHS[@]}"; do | |
echo "Moving /tmp/$BACKUP_NAME to $path..." | |
cp -f /tmp/$BACKUP_NAME "$path" | |
done | |
rm -i /tmp/$BACKUP_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment