Something very scary just happened to me while I was creating a ksh script to rsync mulitple FS between two hosts. Here is the script, notice the 'i' at the end of rsync line, it got put there by mistake. You also see the contents of $FSLIST cat'd below the script. When I ran this, it started to delete files in root's home directory and place files from the fist FS, /banner, into root's home directory. The resolved rsync line in the first instance would have been... rsync -vaz -e "ssh" --delete --exclude-from=/usr/local/adm/rsync.exclude /banner/ backenp650:/banneri When I ran it, the output began like this building file list ... done deleting sysback/C480KIE.tar deleting directory sysback deleting stuff/user/usermigrate2.ksh deleting stuff/user/rmuserdir.ksh deleting stuff/user/rmuser.ksh deleting stuff/user/mkuser5.ksh deleting stuff/user/mkuser4.ksh deleting stuff/user/mkuser3.ksh deleting stuff/user/mkuser2.ksh deleting stuff/user/mkuser1.ksh So I immediately pressed ctrl-c and began restoring my files! :) Did it default to $HOME or ~ because the destination directory did not exist (/banneri) or did I miss something in my observation? "rsyncall.ksh" 15 lines, 449 characters #rsyncall.ksh #rsyncs all fs listed in $FSLIST from localhost to $DHOST FSLIST=/usr/local/adm/rsync.fslist SHOST=`hostname` DHOST=backenp650 date for FS in $(cat $FSLIST); do echo "rsync'ing $FS from $SHOST to $DHOST" rsync -vaz -e "ssh" --delete --exclude-from=/usr/local/adm/rsync.exclude $FS/ $DHOST:$FSi echo "\n" done - END SCRIPT - cat /usr/local/adm/rsync.fslist /banner /banproc /bantest /bantemp /users -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003
On Tue, 30 Dec 2003, Wesley Joyce <wjoyce@uvi.edu> wrote:> Something very scary just happened to me while I was creating a ksh script > to rsync mulitple FS between two hosts. Here is the script, notice the 'i' > at the end of rsync line, it got put there by mistake. You also see the > contents of $FSLIST cat'd below the script. When I ran this, it started to > delete files in root's home directory and place files from the fist FS, > /banner, into root's home directory. The resolved rsync line in the first > instance would have been... > > rsync -vaz -e "ssh" --delete --exclude-from=/usr/local/adm/rsync.exclude > /banner/ backenp650:/banneriNope. The destination in your script was "$DHOST:$FSi" $FSi is a variable named FSi which does not exist, so a null string was used, leaving your destination as "backenp650:" And that would indeed be using the home directory on the destination. Not bad rsync - bad you! ;-) I would suggest always using --dry-run when debugging scripts like this and then remove it when it looks like things will work as you intended. -- John Van Essen Univ of MN Alumnus <vanes002@umn.edu>