Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep timestamp when gsutil cp

I am new to google cloud storage nearline and test it. I intend to use google cloud storage nearline for backup.

I wonder how to keep files timestamp when I do 'gsutil cp' between local and nearline.

gsutil cp localfile gs://mybucket

Then, uploaded file timestamp is set uploaded time. I want to keep original file timestamp.

like image 503
Shigenobu Nishikawa Avatar asked Nov 01 '25 12:11

Shigenobu Nishikawa


2 Answers

Sorry, you cannot specify the creation time of an object in GCS. The creation time is always the moment that the object is created in GCS.

You can, however, set extra user metadata on objects that you upload. If you'd like, you can record the original creation time of an object there:

$> gsutil cp -h "x-goog-meta-local-creation-time:Some Creation Time" localfile gs://mybucket
like image 124
Brandon Yarbrough Avatar answered Nov 04 '25 02:11

Brandon Yarbrough


When I attempted to perform copy with the following command, the timestamp (Linux "mtime") of local files gets automatically preserved as "goog-reserved-file-mtime" in metadata on Google Cloud Storage.

gsutil cp -r -P $LOCAL_DIR/* gs://$TARGET_BUCKET &
like image 30
Darsen Lu Avatar answered Nov 04 '25 03:11

Darsen Lu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!