Use case – auto-syncing folders

A really common use case is keeping data in sync between the persistent disk of a VM and a specific GCS location, or two GCS locations. The gsutil rsync function is what we need here.

The source and destination URLs can either be a cloud storage bucket or a local directory. So, for example, if you want to sync data between two buckets, you can simply use the following:

gsutil rsync gs://loonycorn-bucket-00 loonycorn-bucket-01
  
Careful on the order of the arguments! If you reverse source and destination with a -d argument, all of your updates will be deleted forever unless you have an archival enabled. The rsync command makes the destination match the source. So rsyncing with an empty source directory makes the destination directory also empty.

It is also possible to specify various additional optional arguments, as follows:

    gsutil rsync [-VARIABLE ARGUMENT] src_url dst_url
    
    VARIABLE ARGUMENTS (OPTIONAL):
    -a = also copies ACL channel
    -c = computes checksum
    -C = copies other files if some incur errors
    -d = deletes data from destination which is not present in source
    -n = "dry run" only lists the files to be copied. Doesn't copy them
    -U = skips unsupported storage class objects
  
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset