GoogleCloudPlatform / GoogleCloudPlatform/gsutil
gsutil cp -P doesn't preserve mtime
- Dominant language
- Python
- Stars
- 918
- Forks
- 335
- PR merge metrics
- No merged PRs in 30d
Description
According to the documentation -P will preserve mtime but it doesn't.
```
$ gsutil --version
gsutil version: 4.28
$ gsutil help cp | fgrep -A 10 -- '-P'
-P Causes POSIX attributes to be preserved when objects are
copied. With this feature enabled, gsutil cp will copy fields
provided by stat. These are the user ID of the owner, the group
ID of the owning group, the mode (permissions) of the file, and
the access/modification time of the file. For downloads, these
attributes will only be set if the source objects were uploaded
with this flag enabled.
On Windows, this flag will only set and restore access time and
modification time. This is because Windows doesn't have a
notion of POSIX uid/gid/mode.
$ gsutil rm gs://destination_bucket//20170122-24/subdir/basebackups_005/base_000000010000018400000078_02183632/extended_version.txt
Removing gs://destination_bucket//20170122-24/subdir/basebackups_005/base_000000010000018400000078_02183632/extended_version.txt...
/ [1 objects]
Operation completed over 1 objects.
$ gsutil -m cp -P -r 'gs://source_bucket//subdir/basebackups_005/base_000000010000018400000078_02183632/extended_version.txt' 'gs://destination_bucket//20170122-24/subdir/basebackups_005/base_000000010000018400000078_02183632/'
Copying gs://source_bucket//subdir/basebackups_005/base_000000010000018400000078_02183632/extended_version.txt [Content-Type=text/plain]...
- [1/1 files][ 109.0 B/ 109.0 B] 100% Done
Operation completed over 1 objects/109.0 B.
$ gsutil ls -l gs://source_bucket//subdir/basebackups_005/base_000000010000018400000078_02183632/extended_version.txt
109 2017-01-25T06:11:58Z gs://source_bucket//subdir/basebackups_005/base_000000010000018400000078_02183632/extended_version.txt
TOTAL: 1 objects, 109 bytes (109 B)
$ gsutil ls -l gs://destination_bucket//20170122-24/subdir/basebackups_005/base_000000010000018400000078_02183632/extended_version.txt
109 2018-03-07T17:16:37Z gs://destination_bucket//20170122-24/subdir/basebackups_005/base_000000010000018400000078_02183632/extended_version.txt
TOTAL: 1 objects, 109 bytes (109 B)
```
Source mtime: 2017-01-25T06:11:58Z
Destination mtime: 2018-03-07T17:16:37Z
I am the owner of the destination bucket and have legacy owner permissions on the source bucket.
Contributor guide
Assessment
This issue has not been assessed yet.