Here is my source dir structure:
../openwrt
../openwrt/BackupOfPackages
../openwrt/BackupOfSettings
../openwrt/BackupOfImages
I want to use rsync to mirror that to the destination dir. I only want to rsync files in the three sub-directories and I only want to sync files with extension:
.installed
from the BackupOfPackages
folder
.img.gz
from the BackupOfImages
folder
.tar.gz
from the BackupOfSettings
folder
In my source dir I have a mixture of all sorts of files in the basedir "openwrt" and in each of the sub dirs. However as above, I only want to sync specific file types from specific sub-dirs.
Here is my rsync command:
openWrtPath="/mnt/usb/openwrt/"
ncpPath="/media/myCloudDrive/openwrt"
rsync -vvrit --include='/' --include='BackupOfSettings/' --include='BackupOfSettings/**.tar.gz' --include='BackupOfPackages/' --include='BackupOfPackages/**.installed' --include='BackupOfImages/' --include='BackupOfImages/**.img.gz' --exclude='/*' --delete --delete-excluded $openWrtPath ncp:$ncpPath
When I run the command this is what it shows and hides. It correctly hides opkg.installed and "New Folder" from the basedir but does not hide file types such as .installed from BackupOfSettings and BackupOfImages etc..
Rsync syncs almost everything from the source to the destination?
How do I change my rsync command to only copy files with extension:
.installed
to the BackupOfPackages
folder
.img.gz
to the BackupOfImages
folder
.tar.gz
to the BackupOfSettings
folder
i.e: To correctly hide any file types that should not be transferred to the destination from the various sub-dirs even if they exist in those sub dirs on the source machine.
UPDATE
Right after I posted I think I found the answer.. when I change --exclude='/*'
to --exclude='*'
it seems to work as I want. Can someone explain the difference between those two excludes?
Does '/*'
mean: "Exclude everything in the basedir (openwrt) and this does not apply to sub-directories of the basedir"?
Thank you!