Search code examples
rsync

Move/rsync while excluding some patterns


I have several TB of photos, spread throughout subfolders. Each photo has an original, a watermarked resized version, and a thumbnail.

Named as such:

img1001.jpg img1001_w.jpg img1001_t.jpg

DSC9876.jpg DSC9876_w.jpg DSC9876_t.jpg

etc etc.

What I need to do, is move all of the originals to a different server. Presumably rsync is the best tool for this?

Is it possible to rsync a directory, while excluding any files that end in _t.jpg or _w.jpg? I'm not concerned about possible edge cases where the original file ends with either of those, as there are no such cases in my data.

Or am I better off just rsync'ing the whole lot, and then selectively deleting the _t & _w files from the destination?

Thanks


Solution

  • Yes, rsync is a good choice. Also because it works incremental so you can stop and start it when needed. By default rsync does not delete anything on remote, I believe. Yes, you can sync whole directory structures. It is possible exclude files or folders from syncing.

    I think I'm using a command like

    rsync -av [--exclude <excludes-file>] <source> <destination>