![rsync硬盘同步](https://i-blog.csdnimg.cn/blog_migrate/3482dba7d0e34f867f333f19ac147e51.png)
rsync硬盘同步
![](https://i-blog.csdnimg.cn/blog_migrate/ee696b3068a69e1eb1007b8f76930a95.png)
If you are just getting started with rsync for the first time and have multiple large hard drives to make backups of, is it safe to actually use one or more of them during the long process? Today’s SuperUser Q&A post has the answer to a worried reader’s question.
如果您是刚开始使用rsync并具有多个大型硬盘来进行备份,那么在漫长的过程中实际使用其中一个或多个硬盘是否安全? 今天的《超级用户问答》帖子解答了一个担心的读者的问题。
Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.
今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。
问题 (The Question)
SuperUser reader All wants to know if it is safe to use a hard drive while rsync is running:
超级用户阅读器所有用户都想知道在rsync运行时使用硬盘是否安全:
I plan to backup my collection of large hard drives using rsync and anticipate that it will take a few days. Is it safe to use the original hard drive (adding files) while rsync is working or it is better to leave the hard drives untouched until rsync is completely finished?
我计划使用rsync备份我的大型硬盘驱动器集合,预计将需要几天时间。 在rsync正常工作时使用原始硬盘驱动器(添加文件)是否安全?还是在rsync完全完成之前让硬盘保持不变?
Is it safe to use a hard drive while rsync is running?
在rsync运行时使用硬盘驱动器安全吗?
答案 (The Answer)
SuperUser contributor Michael Kjorling has the answer for us:
超级用户贡献者Michael Kjorling为我们提供了答案:
As others have already pointed out, it is safe to read from the source disk or use the target disk outside of the target directory while rsync is running. It is also safe to read within the target directory, especially if the target directory is being populated exclusively by the rsync run.
正如其他人已经指出的那样,在rsync运行时,从源磁盘读取或使用目标目录外部的目标磁盘是安全的。 在目标目录中进行读取也是安全的,特别是如果目标目录仅由rsync运行填充。
What is not generally safe, however, is to write within the source directory while rsync is running. “Write” is anything that modifies the content of the source directory or any subdirectory thereof, so that includes file updates, deletions, creation, etc.
但是,通常不安全的是在rsync运行时在源目录中写入。 “写入”是指修改源目录或其任何子目录的内容的任何内容,因此包括文件更新,删除,创建等。
Doing so will not actually break anything, but the change may or may not actually get picked up by rsync for copying to the target location. That depends on the type of change, whether rsync has scanned that particular directory yet, and whether rsync has copied the file or directory in question yet.
这样做实际上不会破坏任何内容,但是更改可能会或可能不会真正被rsync拾取并复制到目标位置。 这取决于更改的类型,rsync是否已经扫描了该特定目录以及rsync是否已经复制了相关文件或目录。
There is an easy way around that, however. Once rsync has finished, run it again with the same parameters (unless you have some funky deletion parameter; if you do, then be a bit more careful). Doing so will cause rsync to re-scan the source and transfer any differences that were not picked up during the original run.
但是,有一种简单的方法可以解决此问题。 rsync完成后,请使用相同的参数再次运行它(除非您有一些时髦的删除参数;否则,请多加注意)。 这样做将导致rsync重新扫描源并传输在原始运行期间未拾取的任何差异。
The second run should transfer only differences that happened during the previous rsync run, and as such, will be completed much faster. Thus, you can feel free to use the computer normally during the first run, but should avoid making any changes as much as possible to the source during the second run. If you can, strongly consider remounting the source file system as read-only before starting the second rsync run (something like mount -o ro,remount /media/source should do).
第二次运行应仅传输上次rsync运行期间发生的差异,因此将更快地完成。 因此,您可以在第一次运行期间随意正常使用计算机,但应避免在第二次运行期间尽可能对源进行任何更改。 如果可以,在开始第二次rsync运行之前,强烈考虑将源文件系统重新安装为只读(类似于mount -o ro,remount / media / source应该可以)。
Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.
有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程 。
Image Credit: Linux Screenshots (Flickr)
图片来源: Linux屏幕截图(Flickr)
翻译自: https://www.howtogeek.com/294871/is-it-safe-to-use-a-hard-drive-while-rsync-is-running/
rsync硬盘同步