-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bin: Create a new bin including a backup script
The dotfiles bin is added to the PATH and includes a simple rsync-powered drive backup script. I use it to backup my MacBook Pro's SSD drive to an external HDD, but the destination drive name can be edited to match the name of any external drive.
- Loading branch information
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/sh | ||
|
||
# IMPORTANT: Make sure you update the `DST` variable to | ||
# match the name of the destination backup drive | ||
|
||
PROG=$0 | ||
RSYNC="/usr/bin/rsync" | ||
SRC="/" | ||
DST="/Volumes/Macintosh HD/" | ||
EXCLUDE="$HOME/.dotfiles/bin/backup_excludes.txt" | ||
|
||
# -v increase verbosity | ||
# -a turns on archive mode (recursive copy + retain attributes) | ||
# -x don't cross device boundaries (ignore mounted volumes) | ||
# -E preserve executability | ||
# -S handle spare files efficiently | ||
# --delete deletes any files that have been deleted locally | ||
# --exclude-from reference a list of files to exclude | ||
# --delete-excluded | ||
|
||
if [ ! -r "$SRC" ]; then | ||
/usr/bin/logger -t $PROG "Source $SRC not readable - Cannot start the sync process" | ||
exit; | ||
fi | ||
|
||
if [ ! -w "$DST" ]; then | ||
/usr/bin/logger -t $PROG "Destination $DST not writeable - Cannot start the sync process" | ||
exit; | ||
fi | ||
|
||
/usr/bin/logger -t $PROG "Start rsync" | ||
|
||
sudo $RSYNC -vaxE -S --delete --exclude-from=$EXCLUDE "$SRC" "$DST" | ||
|
||
/usr/bin/logger -t $PROG "End rsync" | ||
|
||
# make the backup bootable - comment this out if needed | ||
sudo bless -folder "$DST"/System/Library/CoreServices | ||
|
||
exit 0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.Spotlight-*/ | ||
.Trashes | ||
/afs/* | ||
/automount/* | ||
/cores/* | ||
/dev/* | ||
/Network/* | ||
/private/tmp/* | ||
/private/var/run/* | ||
/private/var/spool/postfix/* | ||
/private/var/vm/* | ||
/Previous Systems.localized | ||
/tmp/* | ||
/Volumes/* | ||
*/.Trash |