如何使用rsync同步以点(.)开头的文件夹?

4

我正在尝试同步一个maildir目录,该目录中的某些文件夹包含以“点”开头的目录。

.Archive/
.Sent Items/

我尝试使用以下代码

$ rsync -pogutr --exclude="." --exclude=".." .*  /home/folder1/mail/domain/user1/ /home/folder2/mail/domain --progress
$ rsync -pogutr --exclude="../" /home/folder1/mail/domain/user1/.*  /home/folder2/mail/domain/ --progress
$ rsync -pogutr --include=".*" /home/folder1/mail/domain/user1  /home/folder2/mail/domain/ --progress

这将同步 /home/folder1/mail/domain/ 目录下的其他子目录到 /home/folder2/mail/domain/user1/ 目录中。

例如,如果 /home/folder1/mail/domain/ 包含用户1、用户2和用户3的子目录。那么用户1、用户2和用户3的所有内容都将在 /home/folder2/mail/domain/user1/ 目录中。

3个回答

0

使用2个rsync命令:1个普通命令和1个用于点文件夹的命令。并指定点并转义它。 我将其用于迁移到docker-poste,并在我的docker主机上运行了此命令:

rsync -e ssh -v -r -u root@10.10.0.7:/home/benny/Maildir/* /mnt/user/docker/poste/data/domains/example.com/benny/Maildir/
rsync -e ssh -v -r -u root@10.10.0.7:/home/benny/Maildir/\.* /mnt/user/docker/poste/data/domains/example.com/benny/Maildir/

0

我伪造了一个邮件目录,其中包含一些点文件夹和文件,它默认情况下正确同步。

$ rsync --recursive --verbose maildir/ maildir-backup
sending incremental file list
created directory maildir-backup
./
.Archive/
.Archive/1
.Archive/2
.Archive/3
.Sent Items/
.Sent Items/bar
.Sent Items/baz
.Sent Items/foo

sent 481 bytes  received 182 bytes  1,326.00 bytes/sec
total size is 0  speedup is 0.00

我甚至尝试了你使用的额外标志(保留所有者、组、时间、权限等)

$ rsync -pogutr --verbose maildir/ maildir-backup
sending incremental file list
created directory maildir-backup
./
.Archive/
.Archive/1
.Archive/2
.Archive/3
.Sent Items/
.Sent Items/bar
.Sent Items/baz
.Sent Items/foo

sent 497 bytes  received 182 bytes  452.67 bytes/sec
total size is 0  speedup is 0.00

你只是不想要或者不需要排除 "this" 文件夹或者其父级文件夹。它们并没有包含在任何路径中。

--exclude="." --exclude=".."

-2

尝试使用unison替代rsync。此外,它同步速度更快。


Unison作为研究项目已不再进行积极开发。 - deejayy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接