#!/bin/csh -f # BackupBritaTo1TB # ----------------------------------------------------------------------------- # Shell script to backup all Brita's files # ----------------------------------------------------------------------------- # Determine whether USB is found, prompting user to plug it in. if (! -d /Volumes/Backup1TB/backup/brita) then echo "Can't find Backup1TB USB drive. Must be plugged in." echo -n "Hit RETURN to exit " > /dev/tty set answer=$< exit 1 endif # rsync options: # -r = Recursive # -v = Verbose # -u = Only newer files. Default is all newer and older files, but not # files with the same time. # -l = Preserve symbolic links, even those pointing outside the copied tree # -t = Preserve times # -p = Preserve permissions (Ignored when copying to USB FAT32 drive) # -o = Preserve owner (Ignored when copying to USB FAT32 drive) # -g = Preserve group (Ignored when copying to USB FAT32 drive) # --modify-window=1 = Treat times as the same even if they differ by as much # as 1 second. Necessary when backing up to FAT or FAT32 # formatted USB drive, where times are always rounded # down to the nearest even-numbered second, so many files # would seem newer on the regular hard drive than on the # USB drive and would always be re-copied. # --stats = Show detailed stats after the copy, like: # Number of files: 47 # Number of files transferred: 0 # Total file size: 87207 bytes # Total transferred file size: 0 bytes # Literal data: 0 bytes # Matched data: 0 bytes # File list size: 789 # File list generation time: 0.001 seconds # File list transfer time: 0.000 seconds # Total bytes sent: 805 # Total bytes received: 20 # --del = Delete files from destination if missing from source rsync -rvltpog --modify-window=1 --stats --del ~/brita/ /Volumes/Backup1TB/backup/brita echo -n "Hit RETURN to exit" > /dev/tty set answer=$<