gcloud storage rsync
SOURCE
DESTINATION
[--additional-headers
=HEADER
=VALUE
] [--canned-acl
=PREDEFINED_ACL
, --predefined-acl
=PREDEFINED_ACL
, -a
PREDEFINED_ACL
] [--checksums-only
] [--no-clobber
, -n
] [--content-md5
=MD5_DIGEST
] [--continue-on-error
, -c
] [--delete-unmatched-destination-objects
] [--dry-run
] [--exclude
=[REGEX
,…], -x
[REGEX
,…]] [--gzip-in-flight
=[FILE_EXTENSIONS
,…], -j
[FILE_EXTENSIONS
,…]] [--gzip-in-flight-all
, -J
] [--no-ignore-symlinks
] [--include-managed-folders
] [--preserve-posix
, -P
] [--recursive
, -R
, -r
] [--skip-if-dest-has-newer-mtime
, -u
] [--skip-unsupported
, -U
] [--decryption-keys
=[DECRYPTION_KEY
,…] --encryption-key
=ENCRYPTION_KEY
] [--cache-control
=CACHE_CONTROL
--content-disposition
=CONTENT_DISPOSITION
--content-encoding
=CONTENT_ENCODING
--content-language
=CONTENT_LANGUAGE
--content-type
=CONTENT_TYPE
--custom-time
=CUSTOM_TIME
--clear-custom-metadata
| --custom-metadata
=[CUSTOM_METADATA_KEYS_AND_VALUES
,…] | --remove-custom-metadata
=[METADATA_KEYS
,…] --update-custom-metadata
=[CUSTOM_METADATA_KEYS_AND_VALUES
,…]] [--if-generation-match
=GENERATION
--if-metageneration-match
=METAGENERATION
] [GCLOUD_WIDE_FLAG …
]
gcloud storage rsync
copies to and updates objects at DESTINATION
to match SOURCE
. SOURCE
must specify a directory, bucket, or bucket subdirectory. gcloud storage rsync
does not copy empty directory trees, since storage providers use a flat namespace.
Note, shells (like bash, zsh) sometimes attempt to expand wildcards in ways that can be surprising. Also, attempting to copy files whose names contain wildcard characters can result in problems.
If synchronizing a large amount of data between clouds you might consider setting up a Google Compute Engine account and running gcloud storage rsync
there. Since gcloud storage rsync
cross-provider data transfers flow through the machine where gcloud storage rsync
is running, doing this can make your transfer run significantly faster than on your local workstation.
data
to the bucket gs://my-bucket/data:
gcloud storage rsync data gs://my-bucket/data
To recurse into directories use --recursive
:
gcloud storage rsync data gs://my-bucket/data --recursive
To make the local directory my-data
the same as the contents of gs://mybucket/data and delete objects in the local directory that are not in gs://mybucket/data:
gcloud storage rsync gs://mybucket/data my-data --recursive --delete-unmatched-destination-objects
To make the contents of gs://mybucket2 the same as gs://mybucket1 and delete objects in gs://mybucket2 that are not in gs://mybucket1:
gcloud storage rsync gs://mybucket1 gs://mybucket2 --recursive --delete-unmatched-destination-objects
To copy all objects from dir1
into dir2
and delete all objects in dir2
which are not in dir1
:
gcloud storage rsync dir1 dir2 --recursive - --delete-unmatched-destination-objects
To mirror your objects across cloud providers:
gcloud storage rsync gs://my-gs-bucket s3://my-s3-bucket --recursive --delete-unmatched-destination-objects
To apply gzip compression to only uploaded image files in dir
:
gcloud storage rsync dir gs://my-bucket/data --gzip-in-flight=jpeg,jpg,gif,png
To skip the file dir/data1/a.txt
:
gcloud storage rsync dir gs://my-bucket --exclude="data./.*\.txt$"
To skip all .txt and .jpg files:
gcloud storage rsync dir gs://my-bucket --exclude=".*\.txt$|.*\.jpg$"
SOURCE
DESTINATION
header1=value1,header2=value2
. Overrides the default storage/additional_headers
property value for this command invocation.
--canned-acl
=PREDEFINED_ACL
, --predefined-acl
=PREDEFINED_ACL
, -a
PREDEFINED_ACL
--checksums-only
--no-clobber
, -n
--content-md5
=MD5_DIGEST
--continue-on-error
, -c
--delete-unmatched-destination-objects
Note: this option can delete data quickly if you specify the wrong source and destination combination.
--dry-run
--exclude
=[REGEX
,…], -x
[REGEX
,…]
Note that this is a Python regular expression, not a pure wildcard pattern. For example, matching a string ending in "abc" is .*abc$
rather than *abc
. Also note that the exclude path is relative, as opposed to absolute (similar to Linux rsync
and tar
exclude options).
For the Windows cmd.exe command line interpreter, use ^
as an escape character instead of \
and escape the |
character. When using Windows PowerShell, use '
instead of "
and surround the |
character with "
.
--gzip-in-flight
=[FILE_EXTENSIONS
,…], -j
[FILE_EXTENSIONS
,…]
When you specify the --gzip-in-flight
option, files being uploaded are compressed in-memory and on-the-wire only. Both the local files and Cloud Storage objects remain uncompressed. The uploaded objects retain the Content-Type
and name of the original files.
--gzip-in-flight-all
, -J
--gzip-in-flight
option described above, but it applies to all uploaded files, regardless of extension.
CAUTION: If some of the source files don't compress well, such as binary data, using this option may result in longer uploads.
--ignore-symlinks
--no-ignore-symlinks
to disable.
--include-managed-folders
--preserve-posix
, -P
For uploads, these attributes are read off of local files and stored in the cloud as custom metadata. For downloads, custom cloud metadata is set as POSIX attributes on files after they are downloaded.
On Windows, this flag will only set and restore access time and modification time because Windows doesn't have a notion of POSIX UID, GID, and mode.
--recursive
, -R
, -r
--skip-if-dest-has-newer-mtime
, -u
--skip-unsupported
, -U
--decryption-keys
=[DECRYPTION_KEY
,…]
--encryption-key
=ENCRYPTION_KEY
projects/{project}/locations/{location}/keyRings/{key-ring}/cryptoKeys/{crypto-key}
. The specified key also acts as a decryption key, which is useful when copying or moving encrypted data to a new location. Using this flag in an objects update
command triggers a rewrite of target objects.
--cache-control
=CACHE_CONTROL
--content-disposition
=CONTENT_DISPOSITION
--content-encoding
=CONTENT_ENCODING
gzip
).
--content-language
=CONTENT_LANGUAGE
en
signifies "English").
--content-type
=CONTENT_TYPE
text/html
).
--custom-time
=CUSTOM_TIME
--clear-custom-metadata
--preserve-posix
, POSIX attributes will still be stored in custom metadata.
--custom-metadata
=[CUSTOM_METADATA_KEYS_AND_VALUES
,…]
--preserve-posix
, POSIX attributes are also stored in custom metadata.
--custom-metadata
or --clear-custom-metadata
, but can be specified together:
--remove-custom-metadata
=[METADATA_KEYS
,…]
--update-custom-metadata
. When used with --preserve-posix
, POSIX attributes specified by this flag are not preserved.
--update-custom-metadata
=[CUSTOM_METADATA_KEYS_AND_VALUES
,…]
--remove-custom-metadata
. When keys overlap with those provided by --preserve-posix
, values specified by this flag are used.
--if-generation-match
=GENERATION
--if-metageneration-match
=METAGENERATION
--access-token-file
, --account
, --billing-project
, --configuration
, --flags-file
, --flatten
, --format
, --help
, --impersonate-service-account
, --log-http
, --project
, --quiet
, --trace-token
, --user-output-enabled
, --verbosity
.
Run $ gcloud help
for details.
gcloud alpha storage rsync
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4