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
.img.gz from the
.tar.gz from the
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..
How do I change my rsync command to only copy files with extension:
.installed to the
.img.gz to the
.tar.gz to the
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.
Right after I posted I think I found the answer.. when I change
--exclude='*' it seems to work as I want. Can someone explain the difference between those two excludes?
'/*' mean: "Exclude everything in the basedir (openwrt) and this does not apply to sub-directories of the basedir"?