Rsync behaviour on harddisc crash

Linux Expert linuxexpert25 at gmail.com
Thu Mar 18 10:30:22 MDT 2010


Yes, it'll sync the source directory (now empty) to Server B, deleting
everything due to the --delete option.

One solution I use is to place a check for the existence of a subdirectory
just before the rsync command in the script.  This was you can make rsync
contingent on the existence of that subdirectory, possibly notifying you via
email when it is not there.

So if you had a subdirectory named "data" directly in the folder you're
syncing, your script (bash) would have something like the following:

*rsync --list server::folder/data 1>/dev/null 2>/dev/null
if [ $? eq 0 ]
  then
    rsync -a –delete server::folder  /folder
  else
    mutt -nx -s "rsync skipped due to missing directory!" <youremail>
fi
*
The idea is that you first tell rsync to list all files under the
folder/data directory.  If that directory doesn't exist, the command will
fail with a non-zero exit value.  This is precisely what you check in the if
conditional.  Now your rsync will either sync properly with the assurance
that the source folder is still there, or notify you via email.

These commands, exit values, etc should all be tested on your server.  You
may not even have mutt installed, or an MTA (ie: Postfix) configured.
Testing is key.

On Thu, Mar 18, 2010 at 8:46 AM, Christian Röder <cr at strassenfeger.tv>wrote:

> I was just pondering:
>
>
>
> Lets look at Server A with one extra harddisc hdb, where hdb1 is mounted at
> /mnt/folder.
>
> /mnt/folder is the folder which should be mirrored on Server B.
>
> So Server B rsyncs
>
>
>
> rsynch -a –delete server::folder  /folder
>
>
>
> from Server A and gets all the new files and deletes all the files, which
> doesn't exist on Server A's /mnt/folder anymore.
>
>
>
> What would happen, if the harddisc hdb would fail?
>
> Will this happen?:
>
>
>
> harddisc hdb failes
>
> hdb1 is not automatically mounted at /mnt/folder
>
> Server B rsyncs from Server A, but /mnt/folder is empty, so rsync deletes
> every file in the mirror folder on Server B?
>
>
>
> Are my assumptions correct?
>
>
>
> Thanks in advance,
>
>
>
> Christian
>
>
>
> --
> Please use reply-all for most replies to avoid omitting the mailing list.
> To unsubscribe or change options:
> https://lists.samba.org/mailman/listinfo/rsync
> Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html<http://www.catb.org/%7Eesr/faqs/smart-questions.html>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/rsync/attachments/20100318/dfae173f/attachment.html>


More information about the rsync mailing list