On UNIX, I am executing an rsync command, from within a script. The command goes something like this: /usr/bin/rsync --verbose --progress --stats --compress --recursive --times --perms --links --safe-links source_dir/ user at target_machine:/parent_path/source_dir In other words, I am replicating source_dir on a remote machine. It ends up next to a lot of sibling, directories, like this: On target_machine /parent_path/source_dir /parent_path/source_dir2 .... /parrent_path/source_dirn Here's my issue. I'd like to use the --delete option in the command above. However, I wake up in a cold sweat worrying about supplying the empty string for source_dir, and thus removing souce_dir, and all it's siblings on target_machine. Now I realize, I can just be extra careful that the variable pointing to source_string is never empty, but I would like to have other fail safe mechanisms in place. I hope I have been sufficiently specific to elicit some suggestions. I guess I am looking for the software equivalent of lots of padlocks on the apartment door. Thanks, Ted Gilchrist -- "Speech, not just for humans" http://www.google.com/profiles/egilchri about.me/ted.gilchrist -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20110510/94c3a646/attachment.html>
> On UNIX, I am executing an rsync command, from within a script. The command goes something like this: > > /usr/bin/rsync --verbose --progress --stats --compress --recursive --times --perms --links --safe-links source_dir/ user at target_machine:/parent_path/source_dir > > In other words, I am replicating source_dir on a remote machine. It ends up next to a lot of sibling, directories, like this: > > On target_machine > > /parent_path/source_dir > /parent_path/source_dir2 > .... > /parrent_path/source_dirn > > Here's my issue. I'd like to use the --delete option in the command above. However, I wake up in a cold sweat worrying about supplying the empty > string for source_dir, and thus removing souce_dir, and all it's siblings on target_machine. > > Now I realize, I can just be extra careful that the variable pointing to source_string is never empty, but I would like to have other fail safe mechanisms in place. > > I hope I have been sufficiently specific to elicit some suggestions. I guess I am looking for the software equivalent of lots of padlocks on the apartment door.You may wish to consider the use of the -n option. The --dry-run option performs a trial run with no changes made. Using this option will allow you to check what will happen prior to actually moving ahead. Just a possibility? --------------------------------------------------------------------- This email is protected by LBackup, an open source backup solution. http://www.lbackup.org
On Tue, May 10, 2011 at 7:51 AM, Ted Gilchrist <egilchri at gmail.com> wrote:> However, I wake up in a cold sweat worrying about supplying the empty string for source_dir, and thus removing souce_dir, and all it's siblings on target_machine.Your best bet is to error-check your args in your script prior to calling rsync.? Compare for dangerous things, like an empty string (or "/"), etc. ..wayne..