Rsync:rsync 不移动某些文件

Rsync:rsync 不移动某些文件

这是我的rsync命令:

rsync -av --progress \
  --exclude=".*" \
  --exclude="target/*" \
  --exclude="src/main/docker" \
  --exclude="src/test" \
  ~/projects/workarea/arxius-linia/backend/ \
  ~/projects/workarea/arxius-linia/gene/backend/

尽管如此,似乎有些东西不同步,因为:

$ diff -qr --exclude=.git --exclude=".*" \
  ~/projects/workarea/arxius-linia/backend \
  ~/projects/workarea/arxius-linia/gene/backend

diff命令给我一些差异:

Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/constants: BookConstants.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/constants: ParticipateConstants.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/controller: BookDocumentationController.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/controller/impl: BookDocumentationControllerImpl.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/controller/impl: ParticipateControllerImpl.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/controller: ParticipateController.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/dao: BookDocDAO.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/dao: BookDocumentationRepository.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/dao: ParticipateDAO.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/dao: ParticipateRepository.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/dao: StatisticsDAO.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/domain: BookDocumentationDomainModel.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/domain: BookUnitDomainModel.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/domain/form: BookDocumentationFormModel.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/domain/form: ParticipateFormModel.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/domain: ParticipateDomainModel.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/service: BookDocumentationService.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/java/net/gencat/clt/arxius/backend/service: ParticipateService.java
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/resources/mailTemplates: MailParticipateArchive.ftlh
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/resources/mailTemplates: MailParticipateValidation.ftlh
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/resources/mailTemplates: SubjectParticipateArchive.ftlh
Only in /home/jeusdi/projects/workarea/arxius-linia/gene/backend/src/main/resources/mailTemplates: SubjectParticipateValidation.ftlh

有任何想法吗?

答案1

您列出的文件Only in ...都位于目标目录下。这意味着这些文件在您运行rsync命令之前就已经存在了。

如果您想从目标目录中删除这些文件,您可以rsync使用其选项运行该命令--delete。这样做会删除目标目录层次结构中不存在于源目录层次结构中的所有文件。--delete-excluded如果您需要删除目标上与任何排除模式匹配的文件,您可能还想使用该选项进行调查。

考虑首先在数据副本上进行测试,或者至少使用--dry-run选项(或-n)来查看rsync将删除哪些文件,并始终进行频繁备份。

相关内容