Skip to main content
Corrections
Source Link
FlexMcMurphy
  • 433
  • 1
  • 9
  • 20

Following on from my other question about rsync.

I am trying to understand how include/exclude directives use patterns to match against the names of files in a source directory to decide which are to be synced to a destination directory.

Apparently * does not match a directory separator, but ** can match one (zero or more of them, to be precise). Can someone explain very clearly what that means with a few rsync commands?

For example:

Here is my source dir structure:

../openwrt
../openwrt/afile.txt
../openwrt/BackupOfPackagesBackupOfSettings
../openwrt/BackupOfPackagesBackupOfSettings/file1.txt
../openwrt/BackupOfPackagesBackupOfSettings/file2.txt
../openwrt/BackupOfPackagesBackupOfSettings/file3.tar.gz
../openwrt/BackupOfSettingsBackupOfPackages
../openwrt/BackupOfImages
../openwrt/BackupOfImages/anotherfile.txt
../openwrt/BackupOfImages/yetanotherfile.jpg

My source and destination directories:

openWrtPath="/mnt/usb/openwrt/"  
ncpPath="/media/myCloudDrive/openwrt"

Example command:
This command will only sync files with extension: tar.gz from the 'BackupOfSettings' folder.

rsync -vvritn --include='BackupOfSettings/' --include='BackupOfSettings/*.tar.gz' --exclude='*' $openWrtPath $ncpPath

The above command recurses through each sub-dir of the source-dir and applies the include and exclude patterns on each file... so how would it ever "see" a directory separator?

Can someone give a scenario, maybe like the above, that demonstrates the * failing and the ** succeeding in matching a directory separator?

Cheers.

Following on from my other question about rsync.

I am trying to understand how include/exclude directives use patterns to match against the names of files in a source directory to decide which are to be synced to a destination directory.

Apparently * does not match a directory separator, but ** can match one (zero or more of them, to be precise). Can someone explain very clearly what that means with a few rsync commands?

For example:

Here is my source dir structure:

../openwrt
../openwrt/afile.txt
../openwrt/BackupOfPackages
../openwrt/BackupOfPackages/file1.txt
../openwrt/BackupOfPackages/file2.txt
../openwrt/BackupOfPackages/file3.tar.gz
../openwrt/BackupOfSettings
../openwrt/BackupOfImages
../openwrt/BackupOfImages/anotherfile.txt
../openwrt/BackupOfImages/yetanotherfile.jpg

My source and destination directories:

openWrtPath="/mnt/usb/openwrt/"  
ncpPath="/media/myCloudDrive/openwrt"

Example command:
This command will only sync files with extension: tar.gz from the 'BackupOfSettings' folder.

rsync -vvritn --include='BackupOfSettings/' --include='BackupOfSettings/*.tar.gz' --exclude='*' $openWrtPath $ncpPath

The above command recurses through each sub-dir of the source-dir and applies the include and exclude patterns on each file... so how would it ever "see" a directory separator?

Can someone give a scenario, maybe like the above, that demonstrates the * failing and the ** succeeding in matching a directory separator?

Cheers.

Following on from my other question about rsync.

I am trying to understand how include/exclude directives use patterns to match against the names of files in a source directory to decide which are to be synced to a destination directory.

Apparently * does not match a directory separator, but ** can match one (zero or more of them, to be precise). Can someone explain very clearly what that means with a few rsync commands?

For example:

Here is my source dir structure:

../openwrt
../openwrt/afile.txt
../openwrt/BackupOfSettings
../openwrt/BackupOfSettings/file1.txt
../openwrt/BackupOfSettings/file2.txt
../openwrt/BackupOfSettings/file3.tar.gz
../openwrt/BackupOfPackages
../openwrt/BackupOfImages
../openwrt/BackupOfImages/anotherfile.txt
../openwrt/BackupOfImages/yetanotherfile.jpg

My source and destination directories:

openWrtPath="/mnt/usb/openwrt/"  
ncpPath="/media/myCloudDrive/openwrt"

Example command:
This command will only sync files with extension: tar.gz from the 'BackupOfSettings' folder.

rsync -vvritn --include='BackupOfSettings/' --include='BackupOfSettings/*.tar.gz' --exclude='*' $openWrtPath $ncpPath

The above command recurses through each sub-dir of the source-dir and applies the include and exclude patterns on each file... so how would it ever "see" a directory separator?

Can someone give a scenario, maybe like the above, that demonstrates the * failing and the ** succeeding in matching a directory separator?

Cheers.

Corrections
Source Link
FlexMcMurphy
  • 433
  • 1
  • 9
  • 20

Following on from my other question about rsync.

I am trying to understand how include/exclude directives use patterns to match against the names of files in a source directory to decide which are to be synced to a destination directory.

Apparently * does not match a directory separator, but ** can match one (zero or more of them, to be precise). Can someone explain very clearly what that means with a few rsync commands?

For example:

Here is my source dir structure:

../openwrt
../openwrt/afile.txt
../openwrt/BackupOfPackages
../openwrt/BackupOfPackages/file1.txt
../openwrt/BackupOfPackages/file2.txt
../openwrt/BackupOfPackages/file3.tar.gz
../openwrt/BackupOfSettings
../openwrt/BackupOfImages
../openwrt/BackupOfImages/anotherfile.txt
../openwrt/BackupOfImages/yetanotherfile.jpg

My source and destination directories:

openWrtPath="/mnt/usb/openwrt/"  
ncpPath="/media/myCloudDrive/openwrt"

Example command:
This command will only sync files with extension: tar.gz from the 'BackupOfSettings' folder.

rsync -vvritn --include='BackupOfSettings/' --include='BackupOfSettings/*.tar.gz' --exclude='*' $openWrtPath $ncpPath

The above command recurses through each sub-dir of the source-dir and applies the include and exclude patterns on each file... so how would it ever "see" a directory separator?

Can someone give a scenario, maybe like the above, that demonstrates the * succeeding and failing to matchand the ** succeeding in matching a directory separator when it tries to match on it?

Cheers.

Following on from my other question about rsync.

I am trying to understand how include/exclude directives use patterns to match against the names of files in a source directory to decide which are to be synced to a destination directory.

Apparently * does not match a directory separator, but ** can match one (zero or more of them, to be precise). Can someone explain very clearly what that means with a few rsync commands?

For example:

Here is my source dir structure:

../openwrt
../openwrt/afile.txt
../openwrt/BackupOfPackages
../openwrt/BackupOfPackages/file1.txt
../openwrt/BackupOfPackages/file2.txt
../openwrt/BackupOfPackages/file3.tar.gz
../openwrt/BackupOfSettings
../openwrt/BackupOfImages
../openwrt/BackupOfImages/anotherfile.txt
../openwrt/BackupOfImages/yetanotherfile.jpg

My source and destination directories:

openWrtPath="/mnt/usb/openwrt/"  
ncpPath="/media/myCloudDrive/openwrt"

Example command:
This command will only sync files with extension: tar.gz from the 'BackupOfSettings' folder.

rsync -vvritn --include='BackupOfSettings/' --include='BackupOfSettings/*.tar.gz' --exclude='*' $openWrtPath $ncpPath

The above command recurses through each sub-dir of the source-dir and applies the include and exclude patterns on each file... so how would it ever "see" a directory separator?

Can someone give a scenario, maybe like the above, that demonstrates the * succeeding and failing to match a directory separator when it tries to match on it?

Cheers.

Following on from my other question about rsync.

I am trying to understand how include/exclude directives use patterns to match against the names of files in a source directory to decide which are to be synced to a destination directory.

Apparently * does not match a directory separator, but ** can match one (zero or more of them, to be precise). Can someone explain very clearly what that means with a few rsync commands?

For example:

Here is my source dir structure:

../openwrt
../openwrt/afile.txt
../openwrt/BackupOfPackages
../openwrt/BackupOfPackages/file1.txt
../openwrt/BackupOfPackages/file2.txt
../openwrt/BackupOfPackages/file3.tar.gz
../openwrt/BackupOfSettings
../openwrt/BackupOfImages
../openwrt/BackupOfImages/anotherfile.txt
../openwrt/BackupOfImages/yetanotherfile.jpg

My source and destination directories:

openWrtPath="/mnt/usb/openwrt/"  
ncpPath="/media/myCloudDrive/openwrt"

Example command:
This command will only sync files with extension: tar.gz from the 'BackupOfSettings' folder.

rsync -vvritn --include='BackupOfSettings/' --include='BackupOfSettings/*.tar.gz' --exclude='*' $openWrtPath $ncpPath

The above command recurses through each sub-dir of the source-dir and applies the include and exclude patterns on each file... so how would it ever "see" a directory separator?

Can someone give a scenario, maybe like the above, that demonstrates the * failing and the ** succeeding in matching a directory separator?

Cheers.

Source Link
FlexMcMurphy
  • 433
  • 1
  • 9
  • 20

rsync - What is the difference between using * and ** in the exclude directive?

Following on from my other question about rsync.

I am trying to understand how include/exclude directives use patterns to match against the names of files in a source directory to decide which are to be synced to a destination directory.

Apparently * does not match a directory separator, but ** can match one (zero or more of them, to be precise). Can someone explain very clearly what that means with a few rsync commands?

For example:

Here is my source dir structure:

../openwrt
../openwrt/afile.txt
../openwrt/BackupOfPackages
../openwrt/BackupOfPackages/file1.txt
../openwrt/BackupOfPackages/file2.txt
../openwrt/BackupOfPackages/file3.tar.gz
../openwrt/BackupOfSettings
../openwrt/BackupOfImages
../openwrt/BackupOfImages/anotherfile.txt
../openwrt/BackupOfImages/yetanotherfile.jpg

My source and destination directories:

openWrtPath="/mnt/usb/openwrt/"  
ncpPath="/media/myCloudDrive/openwrt"

Example command:
This command will only sync files with extension: tar.gz from the 'BackupOfSettings' folder.

rsync -vvritn --include='BackupOfSettings/' --include='BackupOfSettings/*.tar.gz' --exclude='*' $openWrtPath $ncpPath

The above command recurses through each sub-dir of the source-dir and applies the include and exclude patterns on each file... so how would it ever "see" a directory separator?

Can someone give a scenario, maybe like the above, that demonstrates the * succeeding and failing to match a directory separator when it tries to match on it?

Cheers.