-
-
Save tzarskyz/6822095 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env sh | |
# | |
# This script backs up your flash drive to a local folder. If you're also | |
# using a backup system such as Time Machine (and you are, right?), this | |
# ensures you will have a snapshot of your flash drive the last time you | |
# plugged it in. Time Machine will then capture the folder, thus | |
# automatically creating time-based backups for even your portable storage! | |
# | |
# If you use launchd to run this script whenever you plug your flash drive | |
# into your Mac, you don't even need to think about it. Full instructions on | |
# how to do it here: | |
# http://www.macresearch.org/tutorial_backups_with_launchd | |
# | |
# Questions or comments? [email protected] | |
# | |
# This script is public domain. No rights are asserted and no warranty of | |
# its effects is provided. You're on your own! | |
# Name of the flash drive that you're backing up. (Case sensitive) | |
VOLNAME="THUMB DRIVE" | |
# Location of volume to back up. | |
BACKUPFROM=/Volumes/$VOLNAME | |
# The directory where the backup copy will live. | |
BACKUPTO=$HOME/Backups/$VOLNAME | |
# Excludes file. Contains wildcard patterns (1 per line) of files to exclude. | |
EXCLUDES=$HOME/.gitignore | |
# Options. | |
OPTS="--archive --compress --delete --delete-excluded --update" | |
# Explanation of options: | |
# | |
# --archive: Runs the backup in archive mode (recurse through directories, | |
# copy symlinks, retain permissions modification times, groups | |
# and owners) | |
# | |
# --compress: Compress file data during the transfer. | |
# | |
# --delete-excluded: Deletes excluded files from backup destination. | |
# | |
# --force: Force deletion of deleted directories in destination directory. | |
# | |
# --update: Update only (don't overwrite newer files). | |
# It sometimes takes a few moments for the drive to fully mount, so wait a bit. | |
sleep 10 | |
# Run backup. | |
rsync $OPTS --exclude-from="$EXCLUDES" "$BACKUPFROM" "$BACKUPTO" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment