Brian Tully
Brian Tully

Reputation: 43

rsync will not exclude hidden files in gsutil 4.15

Previously gsutil appeared to not upload hidden files. Now hidden files cannot be prevented from upload. Using the -x command with either .*/\\..* or .*/[.].* still uploads both hidden files and directories. This is with a local directory up to a bucket.

Is there a different expression that is required?

Upvotes: 4

Views: 1515

Answers (3)

Chupaka
Chupaka

Reputation: 208

As the regexp is not tied to the edges of the string, .*'s at the beginning and at the end are not necessary, plus we can use grouping to simplify (sic!) a bit:

gsutil rsync -x '(^|/)\.' source dest

Where \. is the dot itself and (^|/) states that the dot should follow either the beginning of file name (^) or a / - a dot file in a subfolder.

Upvotes: 0

surj
surj

Reputation: 4903

This works for both hidden files and directories, at any spot in the path:

gsutil rsync -x '.*/\..*|^\..*' source dest

The other answer didn't work for me.

Upvotes: 1

Mike Schwartz
Mike Schwartz

Reputation: 12145

The -x exclude option should work:

gsutil rsync -x '\..*|./[.].*$' source-dir gs://your-bucket

You can learn more about it from the [official documentation].

Upvotes: 2

Related Questions