Rsync bash 脚本和硬链接文件
我正在创建一个 bash 脚本来使用 rsync 备份我的文件。
备份全部来自一个目录。 我只想备份新的或修改的文件。
目前,我告诉 rsync 备份目录,并检查与上次备份相比的文件。
我这样做的方式是
THE_TIME=`date "+%Y-%m-%dT%H:%M:%S"`
rsync -aP --link-dest=/Backup/Current /usr/home/user/backup /Backup/Backup-$THE_TIME
rm -f /Backup/Current
ln -s /Backup/Backup-$THE_TIME /Backup/Current
我很确定我的语法是正确的。每个备份都会检查“当前”文件夹,并仅在必要时上传。然后,它将删除当前文件夹,并重新创建指向刚刚执行的最新备份的符号链接。
当我运行脚本时出现错误:
rsync:链接“/Backup/Backup-2010-08-04-12:21:15/dgs1200series_manual_310.pdf”
=> /备份/当前/dgs1200series_manual_310.pdf 失败:不支持操作(45)
主机操作系统正在运行 HFS 文件系统,该系统支持硬链接。我试图弄清楚是否有其他东西不支持这一点,或者我的代码是否有问题。
感谢您的任何帮助
编辑:
我能够在本地计算机上创建硬链接。 我还可以在远程服务器上创建硬链接(本地登录时) 通过 afp 安装时,我无法在远程服务器上创建硬链接。即使这两个文件都存在于服务器上。
我猜这是 afp 的限制。
I am creating a bash script to backup my files with rsync.
Backups all come from a single directory.
I only want new or modified files to be backed up.
Currently, I am telling rsync to backup the dir, and to check the files compared to the last backup.
The way I am doing this is
THE_TIME=`date "+%Y-%m-%dT%H:%M:%S"`
rsync -aP --link-dest=/Backup/Current /usr/home/user/backup /Backup/Backup-$THE_TIME
rm -f /Backup/Current
ln -s /Backup/Backup-$THE_TIME /Backup/Current
I am pretty sure I have the syntax correct for this. Each backup will check against the "Current" folder, and upload only as necesary. It will then delete the Current folder, and re-create the symlink to the newest backup it just did.
I am getting an error when I run the script:
rsync: link "/Backup/Backup-2010-08-04-12:21:15/dgs1200series_manual_310.pdf"
=> /Backup/Current/dgs1200series_manual_310.pdf
failed: Operation not supported (45)
The host OS is running HFS filesystem, which supports hard linking. I am trying to figure out if something else is not supporting this, or if I have a problem in my code.
Thanks for any help
Edit:
I am able to create a hard link on my local machine.
I am also able to create a hard link on the remote server (when logged in locally)
I am NOT able to create a hard link on the remote server when mounted via afp. Even if both files exist on the server.
I am guessing this is a limitation of afp.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以防万一您的命令行只是一个示例:请务必始终使用绝对路径名指定链接目标目录!这是我花了很长时间才弄清楚的事情……
Just in case your command line is only an example: Be sure to always specify the link-dest directory with an absolute pathname! That’s something which took me quite some time to figure out …
手册页中有两件事值得检查:
和
您是否打开了“忽略所有权”选项?您拥有什么版本的
rsync
?另外,您是否尝试过在命令行中使用 ln 手动创建类似的硬链接?
Two things from the man page stand out that are worth checking:
and
Do you have the "ignore ownership" option turned on? What version of
rsync
do you have?Also, have you tried manually creating a similar hardlink using
ln
at the command line?我不知道这是否是同一个问题,但我知道当目标是 FAT32 分区并且文件名中包含“:”(冒号)时,rsync 无法同步文件。 [源文件系统是 ext3,目标是 FAT32]
尝试重新配置
date
命令,使其不使用冒号,看看是否有影响。例如
I don't know if this is the same issue, but I know that rsync can't sync a file when the destination is a FAT32 partition and the filename has a ":" (colon) in it. [The source filesystem is ext3, and the destination is FAT32]
Try reconfiguring the
date
command so that it doesn't use a colon and see if that makes a difference.e.g.