Skip to content

Instantly share code, notes, and snippets.

@iambibhas
Last active December 29, 2015 08:48
Show Gist options
  • Save iambibhas/7645480 to your computer and use it in GitHub Desktop.
Save iambibhas/7645480 to your computer and use it in GitHub Desktop.
Backup script to run on cron or on demand
# Destination directory where backups should be put
DEST_DIR="/media/bibhas/My Passport/Backup"
# List of directories to backup
# each directory in a new line
DIRS="/mnt/Works/
/etc/
/home/bibhas/
"
for d in $DIRS
do
echo "Backing up $d"
SLUG="$(echo -n "${d}" | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z)"
tar --exclude="venv" -cjvf "$DEST_DIR/backup$SLUG`date +"%d-%b-%y"`.tar.bz" $d
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment