#!/bin/bash # Updates an archive on your USB drive with *small* files that you have changed # today. # It does NOT clear out old files from the USB drive - use rm -rf for that. # Copyleft 2005 by Rob Reid under the GNU Public License version 2. # Suggested crontab: # # use /bin/tcsh to run commands, no matter what /etc/passwd says # SHELL=/bin/tcsh # # # # 10:25AM on weekdays # 25 10 * * 1-5 $HOME/bin/updateusb # # 12:25PM on weekdays # 25 12 * * 1-5 $HOME/bin/updateusb # # 3:25PM on weekdays # 25 15 * * 1-5 $HOME/bin/updateusb ######################## Configuration variables ########################## # Mount point of the destination drive. usb="/media/usbdisk" # Destination directory. destdir="$usb/from/${HOST%%\.*}/dailyupdate/" # Files larger than this (in kilobytes) will be ignored... maxkb=400 # ...and so will these subdirectories of your home directory. excludedirs=".galeon .mozilla .elinks .gconf .gconfd .adobe" ##################### End of configuration variables ###################### fc="find $HOME" for ed in $excludedirs; do fc="$fc -path $HOME/$ed -prune -o" done fc="$fc -daystart -mtime -1 -size -${maxkb}k -type f -print" fcres=$($fc) # Don't check for errors; just let mount complain to the screen (or email if # run by cron). The most common error is usually just that the drive is # already mounted. (mount does use different return values but I'm too lazy to # look up how to use them.) mount $usb for nf in $fcres; do rsync -ptgR $nf $destdir done # Forces a flush. umount $usb