- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我会先尝试定位问题。我们有一个构建为大型文件树的项目。该构建有数百 MB,包含许多(较小的)文件,其中只有一小部分在构建之间发生变化。我们希望保留这些构建的一些历史记录,并且为了有效地做到这一点,我们希望硬链接(hard link)在构建之间不会更改的文件。为此,我们使用 rsync
(作为 cp
的更强大的兄弟),使用选项 --link-dest
从本地源到本地目标> 用于执行硬链接(hard link)魔术。
这适用于增量构建:大多数文件未被触及,rsync
正确执行硬链接(hard link)技巧。使用完全重新编译构建(出于与此处无关的原因我们必须这样做),事情似乎没有按预期工作。由于重新编译,所有文件都获得了新的时间戳,但就内容而言,大多数文件仍与之前的构建相同。但即使我们使用 rsync
和 --checksum
选项(所以 rsync
“同步”/基于内容的硬链接(hard link),而不是文件大小+时间戳) , 不再有任何硬链接(hard link)。
我试图用这个简单的 (bash) 脚本来隔离/说明问题:
echo "--- Start clean"
rm -fr src build*
echo "--- Set up src"
mkdir src
echo hello world > src/helloworld.txt
echo "--- First copy with src as hardlink reference"
rsync -a --checksum --link-dest=$(pwd)/src src/ build1/
echo "--- Second copy with first copy as hardlink reference"
rsync -a --checksum --link-dest=$(pwd)/build1 src/ build2/
echo "--- Result (as expected)"
ls -ali src/helloworld.txt build*/helloworld.txt
echo "--- Sleep to have reasonable timestamp differences"
sleep 2
echo "--- 'Remake' src, but with same content"
rm -fr src/helloworld.txt
echo hello world > src/helloworld.txt
echo "Third copy with second copy as hardlink reference"
rsync -a --checksum --link-dest=$(pwd)/build2 src/ build3
# Using --modify-window=10 gives results as expected
# rsync -a --modify-window=10 --link-dest=$(pwd)/build2 src/ build3
echo "Final result, not as expected"
ls -ali src/helloworld.txt build*/helloworld.txt
第一个结果如预期:所有三个副本都是硬链接(hard link)的(相同的 inode)
30157018 -rw-r--r-- 3 stefaan staff 12 May 10 01:28 build1/helloworld.txt
30157018 -rw-r--r-- 3 stefaan staff 12 May 10 01:28 build2/helloworld.txt
30157018 -rw-r--r-- 3 stefaan staff 12 May 10 01:28 src/helloworld.txt
最终结果不符合预期/期望:
30157018 -rw-r--r-- 2 stefaan staff 12 May 10 01:28 build1/helloworld.txt
30157018 -rw-r--r-- 2 stefaan staff 12 May 10 01:28 build2/helloworld.txt
30157026 -rw-r--r-- 1 stefaan staff 12 May 10 01:28 build3/helloworld.txt
30157024 -rw-r--r-- 1 stefaan staff 12 May 10 01:28 src/helloworld.txt
第三个副本 build3/helloworld.txt
没有硬链接(hard link)到 build2
中的副本,即使内容相同,所以校验和检查应该看到这个。
有人知道这里出了什么问题吗?我的期望错了吗?或者 rsync 在从本地同步到本地时是否忽略了 --checksum
选项,例如因为它知道查看 inode 编号比花时间在校验和上更聪明?
最佳答案
问题是使用“-a”标志会强制保留修改时间(隐含地,“-t”)。
如果您改用“-rlpgo”(或在“-a”之后加上“--no-times”),修改时间将不再被考虑保存,因此 inode 将被共享。您仍然必须指定“--size-only”或“--checksum”(后者显然更安全),这样它就不会根据文件时间进行比较。
文档没有明确区分哪些标志用于触发更新,哪些用于控制属性的保存。
关于linux - Rsync with --checksum 从本地到本地?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10525748/
当我使用 --progress 标志运行 rsync 时,我得到有关传输的信息,如下所示。 path/to/file 16 100% 0.01kB/s 0:00:01
为了使用单个 rsync 命令将两个源目录(例如 ~/src1 和 ~/src2)同步到远程系统中的两个独立目标(例如/tgt 和/tgt/sub_tgt),我正在做: rsync ~/src1 ui
从 rsync 手册文档中,我看到通过使用选项 rsync-path,可以指定要在远程计算机上运行的程序以启动 rsync。特别是,该程序可以是一个包装脚本,它在中间调用实际的 rsync 命令,但它
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 6年前关闭。 Improve thi
我在远程主机上有一些文件(在目录中),我想在目录级别以原子方式执行 rsync 以在本地主机上提取文件(在分布式设置中)。我能想到的一种方法是一种非常简单的情况,我可以在本地主机上进行文件备份,然后用
我们有一个 130GB 大小的文件夹,其中包含数百万个微小 (5-20k) 图像文件,我们需要将它从旧服务器 (EC2) 移动到新服务器(德国 Hetzner)。 我们的 SQL 文件 SCP 很快就
我想知道是否有一种方法(命令)可以用来查找 rsync 地址的大小,而无需开始同步? 例如,我如何找到 rsync://mirrors.standaloneinstaller.com/vim/ 的大小
我想同步/Volumes/B/中的所有内容,除了我想全局排除的缓存目录。另外,我不想 rsync 任何其他/Volume/ 我有以下排除文件: + /Volumes/B/*** - Cache/ -
rsync -av --size-only --include="*/" --include="*.jpeg" --exclude="*" ~/alg/temperature/ ~/alg/tmp/
我正在使用 rsync 同步文件夹,如果现有文件已被修改,则对其进行备份。目前所有修改过的文件都备份到一个单独的目录中,以同步时间为后缀。这是使用以下命令: rsync --times --backu
我希望 rsync 排除所有包含具有特定名称的文件的目录,比如“.rsync-exclude”,独立于“.rsync-exclude”文件的内容。 如果文件“.rsync-exclude”只包含“*”
例子: rsync /tmp/fol1/fol2/fol3/foln user@addr:/tmp/fol1/fol2/fol3/foln 我的主要问题是文件夹/tmp/fol1 在远程机器上不存在。
以下命令按预期工作... cp -ur /home/abc/* /mnt/windowsabc/ rsync 相比它有什么优势吗?有没有更好的方法让备份文件夹每 24 小时保持同步? 最佳答案 Rsy
我想从本地计算机到服务器rsync。在不存在的目录上,我希望 rsync 首先在服务器上创建该目录。 我怎样才能做到这一点? 最佳答案 如果要创建的叶目录不止最后一个,您可以先运行单独的 ssh ..
我使用 rsync 来更新我的静态网站。我目前cd到本地网站目录,运行rsync命令,然后在下一行输入密码。我已将我的 rsync 调用保存到一个文本片段中(这样 _rs 就可以扩展到我的调用)。有没
我正在运行如下命令: rsync -vuan "/Volumes/Working/foldername/" "/Volumes/Archive/foldername/" 当文件夹名称包含“/”(如“1
我尝试使用以下命令从服务器进行 rsync,并收到以下错误消息: rsync -e ssh -avz name@home.com:/home/name/. . receiving file list
所以我有这个代码: rsync \ --archive \ --verbose \ --compress \ --delete \ --no-motd \ --ex
我使用 rsync 来更新我的静态网站。我目前cd到本地网站目录,运行rsync命令,然后在下一行输入密码。我已将我的 rsync 调用保存到一个文本片段中(这样 _rs 就可以扩展到我的调用)。有没
我正在运行如下命令: rsync -vuan "/Volumes/Working/foldername/" "/Volumes/Archive/foldername/" 当文件夹名称包含“/”(如“1
我是一名优秀的程序员,十分优秀!