A BASH script to backup a single user home directory, or installed apps or user home dot files.
- tee command
- Should be pre-installed on MacOS
- Clone to system from Github.
git clone https://github.com/bonusbits/backup_macos.git ~/git/
2. Make script executable
sudo chmod +x ~/git/backup_macos/*.sh
3. Create Symlink and aliases for shell Scripts in bash profile
# Backup Scripts
if [ ! -h "/usr/local/bin/backup_macos" ]; then
ln -s "/path/to/clone/backup_macos/backup.sh" /usr/local/bin/backup_macos
fi
# Examples
alias backupjoe="sudo backup_macos -b user -u jdoe -d /Volumes/usbdrive/Backups -r 60 -m 500000"
alias backupapps="sudo backup_macos -b apps -d /Volumes/usbdrive/Backups/ -r 60 -m 300000"
alias backupapps="sudo backup_macos -b dot -d /Volumes/usbdrive/Backups/ -r 60 -m 10000"
Option | Description |
---|---|
-b | Backup Type. [user|dot|apps] (Required) |
-u | Username or home folder name to backup. (Required - IF user type selected) |
-d | Destination backup folder. (Required) |
-m | Max Space in Megabits. How much maximum space to allow in the destination directory. Default: (250000MB) |
-r | Retention Days. How long to keep backups in the destination directory. Default: (14) |
-h | Display Help |
-v | Display Version |
- sudo backup_macos_user.sh -u jdoe -d /Volumes/usbdrive/Backups
- sudo backup_macos_user.sh -u jdoe -d /Volumes/usbdrive/Backups -r 60 -m 500000