LoginSignup
0
0

More than 1 year has passed since last update.

gsutil で rsync するときに特定のファイルやディレクトリを除外したい

Posted at

ここに書いてあることをそのまま書く。issueの中身を見て満足された方は読まなくてもおk。
https://github.com/GoogleCloudPlatform/gsutil/issues/771

gsutil の -x オプションに正規表現を指定することができる。

# 同期の元ディレクトリツリー
tree rsync-test/
rsync-test/
├── dirA
│   └── bar.txt
├── dirB
│   └── baz.txt
├── dirC
│   ├── baq.txt
│   └── dirCA
│       └── bat.txt
└── foo.txt

# dirA と dirCA の文言を含むオブジェクトを除外
gsutil rsync -r -x '^.*dirA.*$|^.*dirCA.*$' rsync-test gs://rsync-test-cball
Building synchronization state...
Starting synchronization...
Copying file://rsync-test/dirB/baz.txt [Content-Type=text/plain]...
Copying file://rsync-test/dirC/baq.txt [Content-Type=text/plain]...
Copying file://rsync-test/foo.txt [Content-Type=text/plain]...
/ [3 files][    0.0 B/    0.0 B]
Operation completed over 3 objects.

# dirA と dirCA の文言を含むオブジェクトは同期されない
gsutil ls gs://rsync-test-cball
gs://rsync-test-cball/foo.txt
gs://rsync-test-cball/dirB/
gs://rsync-test-cball/dirC/

gsutil ls gs://rsync-test-cball/dirB/
gs://rsync-test-cball/dirB/baz.txt

gsutil ls gs://rsync-test-cball/dirC
gs://rsync-test-cball/dirC/baq.txt
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0