2

This is my rsync command:

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

Nevertheless, it seems something is not synchronized since:

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

diff command is getting me some diffs:

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

Any ideas?

1 Answer 1

2

The files that you list as Only in ... are all located under the target directory. What this means is that those files were there before you ran the rsync command.

If you want to remove those files from the target directory, you may run the rsync command with its --delete option. Doing so would delete all files in the target directory hierarchy not present in the source directory hierarchy. You may also want to investigate using the --delete-excluded option if you need to delete files at the target that match any of your exclusion patterns.

Consider testing this on a copy of the data first or at least with the --dry-run option (or -n) to see what files rsync would remove, and always take frequent backups.

7
  • Is there any option in order to keep some directories that only exists in target but doesn't exist in src?
    – Jordi
    Sep 28, 2021 at 8:39
  • @Jordi There is no way to tell rsync to selectively delete files and directories from the target hierarchy when they don't exist at the source. You either delete all that don't exist, or you leave them. If the files fulfill some general criteria (like having a particular filename suffix), it would be easy to go through and delete them with find afterward. You may want to ask a separate question about this if you can't find an existing query that deals with it.
    – Kusalananda
    Sep 28, 2021 at 8:44
  • --exclude will do that for you @Jordi. (Documentation - man rsync - says, "Files that are excluded from the transfer are also excluded from being deleted unless you use the --delete-excluded option or mark the rules as only matching on the sending side") Sep 28, 2021 at 8:50
  • 1
    Exactly. Perhaps --exclude-from rather than --exclude, but the principle is the same: exclusion paths apply on both sides Sep 28, 2021 at 9:49
  • 1
    @roaima Point taken. I won't put this into my answer as it's a follow-up topic. I'll let it stay in the comments.
    – Kusalananda
    Sep 28, 2021 at 9:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .