RSync include only certain file types, or exclude all but…
I was recently working on something for my company and needed to transfer all of our product pictures to my home computer. Unfortunately, all the actual product PNGs are intermingled with their corresponding and huge XCFs and other working files. Thus, I needed to exclude all files except the PNGs. Or, to include only the PNGs.
Here’s how to do it:
#!/bin/bash
rsync --include='*/' --include='*.png' --exclude='*' \
--prune-empty-dirs \
example.com:/path/to/source ./
Thanks to Dude for the tip on pruning empty directories. See his Comment below.
I pulled this from here.
Awesome. Hope everyone searching “rsync exclude everything except” finds this!
Glad it helped!
–prune-empty-dirs
should read
-–prune-empty-dirs
otherwise it gets interpretted at a DRY RUN! -n
Thanks for the heads up… gotta be careful with the old en-dashes…
Most excellent news… speeded up my rpm/dprm synchronisation zillions of percent…
use –prune-empty-dirs (-m) or it will create empty directorys of what you didn’t include
Sweet – just what I needed.