Is using rsync while source is being updated safe?

Is it safe to use rsync when the source filesystem is mounted and writeable, assuming that it may very well be modified while rsync is running? I presume that under race conditions I may not get the latest modifications, but is there any risk of corruption?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Using rsync is fairly safe on read-write mounted file systems. When rsync is started it builds up a file list and then starts to copy those files. This file list is not being updated during the run. The actual data is then copied.

This means when a file changes after rsync has built the file list, it will copy the new content. However, when a new file is added after rsync has built up its file list, this new file is not copied. If a file is deleted after rsync has built the list of files, rsync will warn that it could not copy that file. Keep in mind that rsync is not a snapshot, this means it’s hard to tell at which point in time rsync copied the data.

File system or volume manager snapshots (e.g. using ZFS or LVM), on the other hand, are created instantly and are a consistent snapshot of the file system at a well defined point in time which can then be copied to another host. rsync does not offer this kind of consistency.

EDIT: As others have pointed out in the comments, there’s a chance that rsync might actually corrupt your file. When rsync starts to read a file and an application is writing that file at the same time, you might end up with a corruped file.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x