Is rsync --delete safe in case of disk failure

Posted by enedene on Super User See other posts from Super User or by enedene
Published on 2011-06-21T23:49:54Z Indexed on 2011/06/22 0:25 UTC
Read the original article Hit count: 195

Filed under:
|
|
|
|

I have two data hard drives on my Linux server and I use second as a backup for a first drive.
I use rsync for that purpose. An example would be:

rsync -r -v --delete /media/disk1/ /media/disk2/

What this does is that it copies every file/directory from /media/disk1/ to /media/disk2/ but also deletes any difference. For example, lets say that files A and B but not file C are on disk1, and on disk2 there is no A and B files, but there is C. The result would be that after the command on disk2 I'd have files A and B, but file C would be deleted, just like on disk1.

Now, a rather disastrous scenario had crossed my mind; what if disk1 dies, system continues to work since system files are on my system disk, but when rsync tries to backup my data on disk2 from broken disk1, it deletes all the files from disk2 because it can't read anything on disk1.

Is this a possible scenario, or is there a protection from it build in rsync?

© Super User or respective owner

Related posts about linux

Related posts about backup