DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Backup Script For Linux
This little shell script qbackup.sh is useful for an automatic backup under Debian Linux. It is based on rsync and requires an usb-storage device (an usb hard disc) to be attached to the machine.
hilfe() {
echo "syntax: qbackup.sh [BACKUP-USER] [BACKUP-DEVICE]"
}
BCKUSR="tweiers";
MNTDEV="/dev/sda7";
for i in $*
do
if [ $i = "-h" -o $i = "-help" -o $i = "--help" -o $i = "-help" ]; then
hilfe;
exit 0
fi
done
if [ $1 ]; then
BCKUSR=$1;
fi
if [ $2 ]; then
MNTDEV=$2;
fi
if [ $USER != "root" ]; then
echo -e "Error: You must be root to run qbackup.sh";
exit 1
fi
mount $MNTDEV /mnt/usb-storage
if [ -d /mnt/usb-storage/$BCKUSR ]; then
rsync -av /home/$BCKUSR/ /mnt/usb-storage/$BCKUSR/;
umount /mnt/usb-storage;
exit 0
else
echo "Error: Could not mount storage device";
exit 2
fi
</code





