Backup script using rsync

Here’s a cute little backup script I wrote. Just a little smarts to suit my particular situation. But I did learn how to prompt for a parameter and do a case statement. The rsync command is a very powerful backup tool. On this particular backup drive (Lacie) I have two sets of backups… (/backup1/ and /backup2/). This script prompts me for which one I want to use and does the right thing. I’m also using an exclude list in the form of a txt file to omit browser caches and the like.

#!/bin/bash
read -p “Backup number (1/2)?” choice
case “$choice” in
1 ) echo “1”;;
2 ) echo “2”;;
* ) echo “Failure to communicate, try again.”;exit 1;;
esac
path=”/home/”
pathfrom=”$path.”
pathto=”/media/Lacie/backup$choice$path.”
rsync -avAX –delete –exclude-from ‘/usr/local/bin/backup-exclude.txt’ “$pathfrom” “$pathto”