Created
February 26, 2018 15:36
-
-
Save ahmadawais/a5c2b8121bad027a5d59fe9df6e54c45 to your computer and use it in GitHub Desktop.
MAC: Backup script
This file contains hidden or 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
# Rsync based backup for Mac. | |
# . | |
# Usage: bk ~/path/to/backup/ | |
# E.g. bk ~/Documents/Audio will create /Volumes/AhmadAwais.com/Z-BACKUPS/Users/Documents/Audio backup. | |
function bk() { | |
# Halt the script on any errors. | |
set -e | |
echo "-" | |
# -a is archive mode so it keeps your original created and modified properties. | |
# -v is verbose mode to get a bit of extra output (useful for debugging). | |
# -R is relative mode. It ensures the included paths get created on the target. | |
RS_PARAM="-avR" | |
# The input from user. | |
BK_SRC="$1" | |
# Your backup HDD's volume path. | |
BK_DST="/Volumes/AhmadAwais.com/Z-BACKUPS/" | |
echo "—————————————————————————————" | |
echo "➤ Backing up "$1" :" | |
echo "—————————————————————————————" | |
# The progress bar can be improved. But it works. | |
rsync "$RS_PARAM" --exclude="node_modules" --exclude=".git" "$BK_SRC" "$BK_DST" |\ | |
pv -lep -s $(rsync "$RS_PARAM"n --exclude="node_modules" --exclude=".git" "$BK_SRC" "$BK_DST" | awk 'NF' | wc -l) | |
echo "-" | |
echo "--------------- ✔︎✔︎✔︎ DONE!!! 💯 🎉 ✔✔✔ ---------------" | |
echo "-" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment