0

After some reading and trying rsync copy over only certain types of files using include option I can't get seem to get it to work.

I run the following command:

rsync -zarv -vvv -e ssh --prune-empty-dirs --delete --include="*/" --include="*.csv" 
--include="*.hdf5" --include="*.pickle" --include="*.tar.gz" --include="*.bin" 
--include="*.zip" --include="*.npz" --exclude="*" . user@host.com:/rsync

But at the target it backups any file I have in the directory and subdirectories. delete-before and delete-after does not delete files like .txt or .py. I have also tried the --exclude="*" before the extension includes but I am running 2.6.9 so it should be after as far as I have understood it.

Deleting files on the host machine will just sync them again for whatever reason I don't know.

Andreas
  • 539
  • 1
  • 5
  • 13
  • I am running on macOS Sierra 10.12.6 – Andreas Feb 19 '18 at 10:20
  • I'm voting to close this question as off-topic because it belongs to https://unix.stackexchange.com/ – ceving Feb 19 '18 at 10:34
  • @Amani: `--exclude="*"` will exclude everything except for what is included with `--include`. – l'L'l Feb 19 '18 at 10:37
  • Yes I have already deleted my comment :) – Amani Ben Azzouz Feb 19 '18 at 10:39
  • try `rsync -zarv -vvv -e ssh --prune-empty-dirs --include="*/" --include="*.csv" --include="*.hdf5" --include="*.pickle" --include="*.tar.gz" --include="*.bin" --include="*.zip" --include="*.npz" --exclude="*" . user@host.com:/rsync --delete` .. just add delete at the end of your command – Amani Ben Azzouz Feb 19 '18 at 10:40

2 Answers2

0

Your command looks fine, although try using --delete-excluded instead of --delete.

--delete-excluded - also delete excluded files from destination dirs

It should eliminate any files that are --excluded and not --included on the destination.

l'L'l
  • 44,951
  • 10
  • 95
  • 146
0

Sorry to have bothered. This was a bash issue and not a command issue.

As I was using the command:

exec $COMMAND

instead of

eval $COMMAND

This made god knows what for error but executing it manually (after print) and correctly in bash made it work. Deleting items still seems flaky but that I can try some.

Andreas
  • 539
  • 1
  • 5
  • 13