#!/bin/sh # # Make backups of Windows machine at target.home # # Full backup goes into /backup/target/full/ # Inrementals go into /backup/target/<dayofweek> # # Based on a script by tridge@linuxcare.com # # Written by Brian C. Lane <bcl@brianlane.com> # if /usr/bin/lockfile -r1 /var/lock/target_inc then # Mount the shared drives, exiting on errors mount -t smbfs //target/C /mnt/target/C -o ro,password=pass if [ "$?" -ne 0 ]; then echo "Error Mounting //target/C" exit fi mount -t smbfs //target/D /mnt/target/D -o ro,password=pass if [ "$?" -ne 0 ]; then umount /mnt/target/C echo "Error Mounting //target/D" exit fi mount -t smbfs //target/E /mnt/target/E -o ro,password=pass if [ "$?" -ne 0 ]; then umount /mnt/target/C umount /mnt/target/D echo "Error Mounting //target/E" exit fi mount -t smbfs //target/F /mnt/target/F -o ro,password=pass if [ "$?" -ne 0 ]; then umount /mnt/target/C umount /mnt/target/D umount /mnt/target/E echo "Error Mounting //target/F" exit fi mount -t smbfs //target/G /mnt/target/G -o ro,password=pass if [ "$?" -ne 0 ]; then umount /mnt/target/C umount /mnt/target/D umount /mnt/target/E umount /mnt/target/F echo "Error Mounting //target/G" exit fi sleep 5 # Day of the week for incremental backup BACKUPDIR=`date +%A` # Remove last week's incremental directory rm -rf /backup/target/$BACKUPDIR # rsync the mounted drives to the backup drive rsync -auvW --modify-window=10 --stats --delete \ --backup --backup-dir=/backup/target/$BACKUPDIR \ --exclude "/mnt/" \ --exclude "/proc/" \ --exclude "lost+found/" \ --exclude "/cdrom/" \ --exclude "/floppy/" \ --exclude "/other/" \ --exclude "WIN386.SWP" \ --exclude "pagefile.sys" \ --exclude "Cache/" \ --exclude "C/WINDOWS/Temporary Internet Files/" \ --exclude "RECYCLED/" \ /mnt/target/ /backup/target/full/ sleep 5 umount /mnt/target/C umount /mnt/target/D umount /mnt/target/E umount /mnt/target/F umount /mnt/target/G # Remove the lockfile rm -f /var/lock/target_inc fi