This is a shell script for backing up a configurable $path
to your iCloud Drive or Dropbox folder for off-site storage. Backups are lzma compressed and gpg encrypted using your public gpg key. Additionally, backups are automatically rotated using $keep
.
Prerequisites:
- GPG public key
- iCloud Drive or Dropbox
Procedure (assuming path=/Developer; storage=iCloud; keep=7
):
- Creates archive of
$HOME/Developer
- Compresses archive using lzma
- Encrypts archive using a gpg public key
- Moves archive to an iCloud Drive directory, causing it to sync with iCloud Drive Server
- Rotates backups, keeping the latest 7 backups, and deleting the rest
Ensure the iCloud symlink has been setup if using iCloud Drive:
ln -nfs "$HOME/Library/Mobile Documents/com~apple~CloudDocs" $HOME/iCloud
Write the script to a file and make it executable:
chmod a+x $HOME/scripts/backup
Setup a crontab to backup the directory on a daily basis:
0 0 * * * $HOME/scripts/backup
Or run it manually:
$HOME/scripts/backup