How to skip existing files in gsutil rsync
Asked Answered
K

1

8

I want to copy files between a directory on my local computer disk and my Google Cloud Storage bucket with the below conditions:

1) Copy all new files and folders.

2) Skip all existing files and folders irrespective of whether they have been modified or not.

I have tried to implement this using the Google ACL policy, but it doesn't seem to be working.

I am using Google Cloud Storage admin service account to copy my files to the bucket.

Kiblah answered 30/5, 2018 at 5:31 Comment(1)
This question should be at Server Fault. Look at gsutil cp -n ....Oleson
E
14

As @A.Queue commented, the solution to skip existing files would be the use of the gsutil cp command with the -n option. This option means no-clobber, so that all files and directories already present in the Cloud Storage bucket will not be overwritten, and only new files and directories will be added to the bucket.

If you run the following command:

gsutil cp -n -r . gs://[YOUR_BUCKET]

You will copy all files and directories (including the whole directory tree with all files and subdirectories underneath) that are not present in the Cloud Storage bucket, while all of those which are already present will be skipped.

You can find more information related to this command in this link.

Evin answered 4/6, 2018 at 9:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.