Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3 sync does not preserve permissions across buckets #901

Open
mpchlets opened this issue Aug 27, 2014 · 37 comments
Open

s3 sync does not preserve permissions across buckets #901

mpchlets opened this issue Aug 27, 2014 · 37 comments
Labels
community feature-request A feature should be added or improved. p2 This is a standard priority issue ready-for-review s3copy-extra-data s3sync s3

Comments

@mpchlets
Copy link

When I sync across buckets with a command of:

aws s3 sync s3://bucket1 s3://bucket2

I would expect the files in bucket2 to have the same permissions as the files in bucket1 by default as it is a "sync"

Instead they only have the default permissions.

@kyleknap kyleknap added s3sync and removed bug labels Aug 27, 2014
@kyleknap
Copy link
Member

Do all of the files have the same permissions? Because for now you could run the sync command with --acl to set permissions. However, currently running sync command with no other optional arguments does not look for permissions and ensure when that the object is transferred, it has the same permissions as the original object. We would have to add an additional argument/feature too handle it.

@mpchlets
Copy link
Author

No - if all the files had the same permissions I could use the --acl flag.

This feature is really a must have of a sync mechanism, particularly when you have thousands of files with different permissions and want a true sync across buckets not just a copy of files.

Do you know of another way to get permissions on a per file basis, so I can script this easily enough?

Thanks for helping.

@kyleknap
Copy link
Member

Yeah if you run an aws s3api get-object-acl on each of the objects. You could get acl's. Here are the docs for the command.
http://docs.aws.amazon.com/cli/latest/reference/s3api/get-object-acl.html

@mpchlets
Copy link
Author

OK - thanks that will work, but this feature would still be greatly appreciated in the sync, if not by default, --preserve-s3-acl flag would be just fine.

@kyleknap
Copy link
Member

No problem. Will consider the feature. I believe the reason that the reason it has not been implemented is because the operation itself may be costly. To determine the objects in a s3 bucket a call to ListObjects is made however this does not return the acls for each object. In turn, we would have to go back and run a GetObjectAcl on every object listed, which could take a while if there are thousands of items in the bucket.

@mpchlets
Copy link
Author

As it did take some time for me to discover that the permissions were not synced over, perhaps updating the documentations of s3 to s3 sync to mention that only the data not the permissions are synchronized would save someone else time in the future.

Thanks again

@Chili-Man
Copy link

any updates on this ?

@nikmolnar
Copy link

I added a pull request (#1535) to address this (also other S3-to-S3 transfers, like copy) a few weeks back. Any chance of getting it considered for inclusion?

@ultrahaus
Copy link

Hi, I know it's an old thread, but we solved this through one sync by permission type. Bottom line: you can filter your sync by key name with --exclude and --include, also you can specify the ACL of each sync... So, if you have a pattern of keys with you need to set different permissions, run sync command many times you need with different ACLs options. It's far from ideal, but works!

@jufemaiz
Copy link

Any thoughts from the AWS team?

@mw44118
Copy link

mw44118 commented Jul 6, 2017

I am pushing my git repositories to S3 just for backups. And then when I sync them back down, all sorts of permissions have changed.

All my executable bin files are no longer executable, and git status squawks about it.

@jayannah
Copy link

+1

9 similar comments
@srikiraju
Copy link

+1

@DCarper
Copy link

DCarper commented Nov 9, 2017

+1

@jmoratilla
Copy link

+1

@felipe-vvoosh
Copy link

+1

@Luffles
Copy link

Luffles commented Dec 20, 2017

+1

@winstonwolff
Copy link

+1

@lithiumFlower
Copy link

+1

@david-crowdstreet
Copy link

+1

@ElliottJPerry
Copy link

+1

@JerryArns
Copy link

JerryArns commented Jan 6, 2018

+1, Yes I had my buckets named with a period, had to change to be compatiable for https through cloud front. Synced to new correctly named buckets. Cant access files. Read about permissions. Object level permissions exist. No command to change all object level permissions in a bucket. Wondering how to proceed. The permissions through the aws GUI actaully look the same from both buckets but when looking up the the Access Control List through the cli I see the original bucket had an extra grantee which was not copied over.
{
"Grantee": {
"Type": "Group",
"URI": "http://acs.amazonaws.com/groups/global/AllUsers"
},
"Permission": "READ"
}

@ASayre
Copy link
Contributor

ASayre commented Feb 6, 2018

Good Morning!

We're closing this issue here on GitHub, as part of our migration to UserVoice for feature requests involving the AWS CLI.

This will let us get the most important features to you, by making it easier to search for and show support for the features you care the most about, without diluting the conversation with bug reports.

As a quick UserVoice primer (if not already familiar): after an idea is posted, people can vote on the ideas, and the product team will be responding directly to the most popular suggestions.

We’ve imported existing feature requests from GitHub - Search for this issue there!

And don't worry, this issue will still exist on GitHub for posterity's sake. As it’s a text-only import of the original post into UserVoice, we’ll still be keeping in mind the comments and discussion that already exist here on the GitHub issue.

GitHub will remain the channel for reporting bugs.

Once again, this issue can now be found by searching for the title on: https://aws.uservoice.com/forums/598381-aws-command-line-interface

-The AWS SDKs & Tools Team

This entry can specifically be found on UserVoice at: https://aws.uservoice.com/forums/598381-aws-command-line-interface/suggestions/33168325-s3-sync-does-not-preserve-permissions-across-bucke

@ASayre ASayre closed this as completed Feb 6, 2018
@nchammas
Copy link

nchammas commented Mar 24, 2018

@ASayre - This might be the wrong place to have this discussion, but could you elaborate on why Amazon have awkwardly split the discussions on the AWS CLI across GitHub and UserVoice?

Feature requests seem appropriate here on GitHub. It's relatively easy to filter to just the feature requests, and even sort by the most popular ones:

screen shot 2018-03-24 at 12 34 47 am

GitHub also makes it easy to share code snippets or refer to other issues (like #1060, which is related to this one), and a large portion of the AWS CLI user base are already active here on GitHub.

@jamesls
Copy link
Member

jamesls commented Apr 6, 2018

Based on community feedback, we have decided to return feature requests to GitHub issues.

@jamesls jamesls reopened this Apr 6, 2018
@bmdelaune
Copy link

Anyone come up with a decent solution to get this done? Much needed function.

@david-crowdstreet
Copy link

david-crowdstreet commented May 10, 2018

The above answer forces * to be public-read. That does not preserve permissions.

@yeah007
Copy link

yeah007 commented Aug 21, 2018

What's the progress? I also encounter this issue. Now I just use sync --include/exclude to resolve this issue.

@mw44118
Copy link

mw44118 commented Aug 21, 2018 via email

@marceloagil
Copy link

marceloagil commented Aug 25, 2018

4 years and yet this nightmare continues. I have 10+ millions of files and all with permissions lost during copy. How is possible such a simple thing as keeping permissions happen?

@tsu-shiuan
Copy link

+1

@aaronjensen
Copy link

For anyone else coming here, I was able to use this to copy one bucket to another and keep ACLs: https://github.com/cobbzilla/s3s3mirror/tree/2.1-stable

It's also significantly faster.

@dougmorin
Copy link

For me, i'm using s3 currently to back up my working folders. These include git repo's, and my repo's keep freaking out after all of the permission changes.

For me the solution ended up being to find a way to reset just the permissions per repo. Until AWS fixes their junk, this is the solution for me.

git config --global --add alias.permission-reset '!git diff -p -R --no-color | grep -E "^(diff|(old|new) mode)" --color=never | git apply'

I found the solution here:

https://stackoverflow.com/questions/2517339/how-to-recover-the-file-permissions-to-what-git-thinks-the-file-should-be

@dratwa1337
Copy link

Hi,

I've encountered the same issue - I had a bucket with tons of objects, while some of them should be publicly accessible. I had to copy entire bucket to another one while preserving the ACLs and of course, setting up the ACLs manually would take me a hell of time.

I've made this simple script in python which copies the objects from one bucket to another and also sets up the ACLs for it.

Feel free to take a look:
https://github.com/terminator9999/aws-s3-bucket-copy/

@yaitskov
Copy link

we need aws sub service s3 acl ;)

@pantelis-karamolegkos
Copy link

👍🏻

@kdaily kdaily linked a pull request May 18, 2022 that will close this issue
@tim-finnigan tim-finnigan added the p2 This is a standard priority issue label Nov 10, 2022
@bholzer
Copy link

bholzer commented Mar 25, 2024

A 10-year-old issue and 3-year-old pull request and this problem persists. Why do I still have to resort to a custom or third-party tool to handle such a common case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community feature-request A feature should be added or improved. p2 This is a standard priority issue ready-for-review s3copy-extra-data s3sync s3
Projects
Status: Ready for Review
Development

Successfully merging a pull request may close this issue.