Skip to content

Instantly share code, notes, and snippets.

@manifestinteractive
Created February 12, 2019 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manifestinteractive/3ec8f91ca0a6dd993f4be94560642967 to your computer and use it in GitHub Desktop.
Save manifestinteractive/3ec8f91ca0a6dd993f4be94560642967 to your computer and use it in GitHub Desktop.
Quick Backup Script
#!/bin/bash
# Backup Important Files on Storage Drive
echo -e "\n\033[48;5;22m Starting Storage Backup › Android \033[0m\n"
rsync -hrPul /Volumes/Storage/Android /Volumes/Backup/Storage
echo -e "\n\033[38;5;34m✓ BACKUP SYNCED\033[0m\n"
echo -e "\n\033[48;5;22m Starting Storage Backup › Music \033[0m\n"
rsync -hrPul /Volumes/Storage/Music /Volumes/Backup/Storage
echo -e "\n\033[38;5;34m✓ BACKUP SYNCED\033[0m\n"
echo -e "\n\033[48;5;22m Starting Storage Backup › Plex \033[0m\n"
rsync -hrPul /Volumes/Storage/Plex /Volumes/Backup/Storage
echo -e "\n\033[38;5;34m✓ BACKUP SYNCED\033[0m\n"
echo -e "\n\033[48;5;22m Starting Storage Backup › Projects \033[0m\n"
rsync -hrPul /Volumes/Storage/Projects /Volumes/Backup/Storage
echo -e "\n\033[38;5;34m✓ BACKUP SYNCED\033[0m\n"
# Backup Important Files on Primary Drive
echo -e "\n\033[48;5;22m Starting HD Backup › Backup \033[0m\n"
rsync -hrPul /Backup /Volumes/Backup/HD
echo -e "\n\033[38;5;34m✓ BACKUP SYNCED\033[0m\n"
echo -e "\n\033[48;5;22m Starting HD Backup › Home Folder \033[0m\n"
rsync -hrPul --exclude='.*' --exclude='AndroidStudioProjects' --exclude='Creative Cloud Files' --exclude='Library' --exclude='Public' --exclude='zsh-syntax-highlighting' --exclude="Pictures/Photos Library.photoslibrary" /Users/peter /Volumes/Backup/HD
echo -e "\n\033[38;5;34m✓ BACKUP SYNCED\033[0m\n"
# All Done
echo -e "\033[38;5;34m✓ COMPLETE\033[0m\n"
@manifestinteractive
Copy link
Author

Setup

Obviously this file was created for my needs, but is a quick thing that could be duplicated by anyone with an external drive. I personally prefer the use of rsync for my backups, but the script can be modified easily for your own needs.

chmod 755 backup.sh
./backup.sh

I stick this in the file in the root of my backup drive with a folder structure that is basically this:

backup.sh
HD/
Storage/

Then, whenever I think about it, I plug in the drive and run the backup.sh command. The key here is that I have two drives that I do this with, and it backs up just what I need, and nothing else. So I end up with duplicate backups, and I just knock them out one after another. These backup drives are in addition to my primary external 12TB RAID storage drive.

The output from this script ends up looking like this:

screenshot 2019-02-12 at 1 08 54 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment