Hello,
I've recently started working with Google Cloud as a solution for a remote symbol server for our company, and I am testing the upload process. My end goal is to have an upload command that only uploads the deltas, and also deletes the files that will be deleted in the source (as there would be some cleaning process in the local symbol server).
gcloud storage rsync -r -n --delete-unmatched-destination-objects <LocalFolder> gs://<BucketName>
The issue I'm facing is: without changing absolutely anything in the source folder, if I run the command two times in a row, I end up with nothing in the Bucket > first time I run it - works fine; second time I run it - deletes all the files.
Now my understanding is this is not how it should work, if the files are the same in my local folder and in the Bucket, why is it that it deletes them? I tried even adding the --checksums-only flag, but nothing changes.
Solved! Go to Solution.
After more testing I figured out the --no-clobber/-n flag is not neccessary, the rsync command doesn't upload files that already exist by default. In the end I'm using this command and it's working as I wanted it to
Hello,
Welcome to Google Cloud Community!
I have also tried to replicate your issue with
```gcloud storage rsync -r -n --delete-unmatched-destination-objects <LocalFolder> gs://<BucketName>```
and got the same behavior as yours. But when I ran the same command without option `-n`, I observed that files were not being deleted.
Hence, As a workaround to this issue I would recommend trying without `-n`.
Ideally as per Doc when you use `-n` it should run rsync in "dry run" mode, i.e., just outputting what would be copied or deleted without actually doing any copying/deleting.
It looks like `-n` is not behaving as expected and this could be due to an issue at our end. I would like you to appreciate for bringing this to our notice. However, for reporting bugs/features this is not a proper forum. Hence I am requesting you to raise a public issue tracker with required details and screenshots as you can best explain the scenario over there. Our issue tracker team may prioritize your request and provide you with the assistance you need.
Interesting, I've been following this Doc , because I'm using gcloud not gsutil, because, as in the header of the doc: "gsutil is not the recommended CLI for Cloud Storage. Use gcloud storage commands in the Google Cloud CLI instead."
So which one am I supposed to use? because in gcloud documentation, rsync -n flag is this:
--no-clobber, -n Do not overwrite existing files or objects at the destination. Skipped items will be printed. This option may perform an additional GET request for cloud objects before attempting an upload.
Hello,
Yes, As you have pointed it out correctly it is not recommended to use gsutil for Cloud Storage as mentioned in the public document. Since you are facing issues with gcloud tags, I suggest you use gsutil as a workaround only.
You may also refer to this StackOverflow for comparison b/w gcloud and gsutil. Since gcloud is the recommended command, And as it is not working as intended I suggest once again to raise a public issue tracker.
After more testing I figured out the --no-clobber/-n flag is not neccessary, the rsync command doesn't upload files that already exist by default. In the end I'm using this command and it's working as I wanted it to