Last active
October 27, 2016 07:53
-
-
Save lordloh/2305d23f898837e5bac7c9d7dae42cc5 to your computer and use it in GitHub Desktop.
A script to backup chosen folders to an offline USB hard disk drive.
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
#! /bin/bash | |
# Code by Bharath Bhushan Lohray | |
# https://bharath.lohray.com/ | |
# github: lordloh | |
# bitbucket: lordloh | |
PART_ID="926fc38e-bc7e-467a-953e-25c6555939a0" | |
now=$(date) | |
echo "===== Running at $now =====" | |
if [ -b /dev/disk/by-uuid/"$PART_ID" ]; then | |
echo "Partition Found!" | |
mkdir ~/$PART_ID | |
mount $PART_ID | |
if [ $? -eq 0 ]; then | |
echo "Mounted" | |
# Run backups | |
rsync -r "/home/bharath/hubic/Datasheets" ~/$PART_ID/. | |
rsync -r "/home/bharath/hubic/Harvard Business Review" ~/$PART_ID/. | |
rsync -r "/home/bharath/hubic/IEEE Computer Magazine" ~/$PART_ID/. | |
rsync -r "/home/bharath/hubic/Linux Journal" ~/$PART_ID/. | |
rsync -r "/home/bharath/hubic/MagPi" ~/$PART_ID/. | |
rsync -r "/home/bharath/hubic/Make Magazine" ~/$PART_ID/. | |
rsync -r "/home/bharath/Photos" ~/$PART_ID/. | |
rsync -rl "/home/bharath/Datasets" ~/$PART_ID/. | |
sync | |
df --output=size,used,avail,pcent -h $PART_ID | |
free_space=$(df --output=avail -h $PART_ID) | |
umount $PART_ID | |
pushb "Vault backup done.[$free_space]" | |
if [ $? -eq 0 ]; then | |
echo "Unmounted" | |
rm -Rf ~/$PART_ID | |
now=$(date) | |
echo "===== Done at $now =====" | |
fi | |
fi | |
else | |
echo ":-(" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment