mv - Move/rename objects

mv - Move/rename objects

Synopsis

gsutil mv [-p] src_url dst_url
gsutil mv [-p] src_url... dst_url
gsutil mv [-p] -I dst_url

Description

The gsutil mv command allows you to move data between your local file system and the cloud, move data within the cloud, and move data between cloud storage providers. For example, to move all objects from a bucket to a local directory you could use:

gsutil mv gs://my_bucket/* dir

Similarly, to move all objects from a local directory to a bucket you could use:

gsutil mv ./dir gs://my_bucket

Renaming Groups Of Objects

You can use the gsutil mv command to rename all objects with a given prefix to have a new prefix. This is accomplished by copying each object to a new object with the desired name and deleting the old one. For example, the command:

gsutil mv gs://my_bucket/oldprefix gs://my_bucket/newprefix

would rename all objects under gs://my_bucket/oldprefix to be under gs://my_bucket/newprefix, otherwise preserving the naming structure.

If you do a rename as specified above and you want to preserve ACLs, you should use the -p option (see OPTIONS).

Note that when using mv to rename groups of objects with a common prefix you cannot specify the source URL using wildcards. You need to spell out the complete name:

gsutil mv gs://my_bucket/oldprefix gs://my_bucket/newprefix

If you have a large number of files to move you might want to use the gsutil -m option, to perform a multi-threaded/multi-processing move:

gsutil -m mv gs://my_bucket/oldprefix gs://my_bucket/newprefix

Non-Atomic Operation

Unlike the case with many file systems, the gsutil mv command does not perform a single atomic operation. Rather, it performs a copy from source to destination followed by removing the source for each object.

A consequence of this is that, in addition to normal network and operation charges, if you move a Nearline Storage or Coldline Storage object, deletion and data retrieval charges apply. See the documentation for pricing details.

Options

All options that are available for the gsutil cp command are also available for the gsutil mv command (except for the -R flag, which is implied by the gsutil mv command). Please see the OPTIONS sections of gsutil help cp for more information.

Esta página foi útil? Conte sua opinião sobre:

Enviar comentários sobre…

Precisa de ajuda? Acesse nossa página de suporte.