s3cmd icon indicating copy to clipboard operation
s3cmd copied to clipboard

s3cmd - Preserve doesn't add metadata to directories

Open Chris-Leeworthy opened this issue 1 year ago • 3 comments

I'm currently using s3cmd sync to backup a small linux filesystem to s3.

I noticed that, when recovering files from the bucket the files have the right ownerships and permissions but the directories/folders that contain them do not.

Looking at object metadata in S3 it seems that files have the ownership and permissions metadata but the folders do not.

When I do a recovery I find the files have the right permissions and ownership but they can't be accessed because the containing folders do not.

Ideally I would want sync with --preserve to store metadata for directories as well as the files themselves.

Can this data be stored for folder objects as well as file objects?

Chris-Leeworthy avatar Sep 20 '23 13:09 Chris-Leeworthy

Normally, the concept of "folder" does not exist in S3. Only files and the path to them are stored. This is why empty folders are not saved also.

But there is a new feature in s3cmd that is currently only in MASTER until the next version is released: When you do a local to remote "sync", if you use the "--keep-dirs" option, "folders" will be also saved in s3 with their permissions. And so, when you do a remote to local sync, folders should be restored with the correct permissions.

For more details on how it works, we use kind of "empty files" on the S3 side to keep as a kind of "fake folder". This is almost what would do the web interface of aws s3 when you manually create a folder.

It would be highly appreciated if you could give it a try.

fviard avatar Nov 03 '23 23:11 fviard

@Chris-Leeworthy Would it be possible for you to give a try to the v2.4.0 version with the "-k" flag (in addition with the preserve), to see if your issue is resolved?

fviard avatar Dec 13 '23 22:12 fviard

Thanks @fviard I will give it a try when I'm back at work on Monday and let you know.

Chris-Leeworthy avatar Dec 16 '23 13:12 Chris-Leeworthy