4
votes

I'm trying to sync a local directory with a Google Cloud Storage bucket, but exclude certain file types. I can do one exclusion just fine using:

gsutil rsync -d -n -x ".\*\\.txt$" "localdir" gs://bucketnamehere

This command runs successfully, and does indeed excludes txt files successfully.

However, if I run the exact example that is given on the rsync FAQ:(https://cloud.google.com/storage/docs/gsutil/commands/rsync)

gsutil rsync -d -n -x ".\*\\.txt$|.*\\.jpg$" "localdir" gs://bucketnamehere

it returns the error:

The filename, directory name, or volume label syntax is incorrect.

This is with the Google Cloud SDK installed on a Windows Server 2012 machine. If anyone has any ideas on how to do multiple exclusions that would be great!

Thank you.

2
I just wanted to add that I've tried that multiple exclusions syntax in both CMD and PowerShell, and it does not work in either. - IT Edlen

2 Answers

0
votes

If like it said the pattern is a regular expression, I'll try this:

gsutil rsync -d -n -x ".\*\\.[txt|jpg]$" "localdir" gs://bucketnamehere
0
votes

I raised a call with Google for this. The correct syntax for Windows (PowerShell specifically) to exclude *.txt and a folder named log in c:temp, needs to have the string surrounded by single quotes as follows:

gsutil rsync -r -x '".*\.txt$^|log"' c:\temp gs://blahblahblah

I'll expand it here with spaces so that you can see the difference as it's not that clear when they're bunched together:

gsutil rsync -r -x ' ".*\.txt$^|log" ' c:\temp gs://blahblahblah

Enjoy