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

expire command should allow setting multiple rules with different prefixes #863

Open
kdvolder opened this issue Apr 24, 2017 · 6 comments
Open

Comments

@kdvolder
Copy link

For example:

I attempted to set expiration times for several folders like this:

s3cmd expire s3://my.bucket \
    --expiry-prefix weekly --expiry-days 7 \
    --expiry-prefix monthly --expiry-days 30

But it seems the effect is only to apply the last provided rule.

I've also tried adding the rules one by one (by separate commands) but the effect is the same. The last command overwrites the previous one instead of adding an additional rule.

@kdvolder
Copy link
Author

Note: s3 does allow multiple rules for a bucket (upto 100 according to this: https://aws.amazon.com/blogs/aws/amazon-s3-object-expiration/)

@Dhimantjadeja
Copy link

Does this command remove the object from S3 bucket after the specified number of days in --expiry-days ?

@pdrocaldeira
Copy link

pdrocaldeira commented Apr 2, 2018

Almost a year and nothing changed I think.
Is there a workaround?

@kdvolder
Copy link
Author

kdvolder commented Apr 4, 2018

Is there a workaround?

Define the rules using something other than s3cmd? Other than that I couldn't come up with anything.

@pdrocaldeira
Copy link

pdrocaldeira commented Apr 4, 2018

In stack overflow they suggest aws-cli but it have the same problem :(

https://stackoverflow.com/questions/49615977/multiple-lifecycles-s3cmd

@tgmedia-nz
Copy link

tgmedia-nz commented Jun 24, 2019

Might be old but you CAN use awscli, like so

s3bucket-lifecycle-policy.json:

{
    "Rules": [
        {
            "Expiration": {
                "Days": 61
            },
            "ID": "Y2Q1YzIwNGItY2YxNS00ZTdkLWFkMzQtYTYxNmExNTY3YWIz",
            "Prefix": "daily-backup",
            "Status": "Enabled",
            "AbortIncompleteMultipartUpload": {
                "DaysAfterInitiation": 7
	    }
        },
        {
            "Expiration": {
                "Days": 40
            },
            "ID": "Y2Q1YzIwNGItY2YxNS00asdfasfsfYxNmExNTY3YWIz",
            "Prefix": "dbbackups",
            "Status": "Enabled",
            "AbortIncompleteMultipartUpload": {
                "DaysAfterInitiation": 7
            }
        }
    ]
}

aws s3api put-bucket-lifecycle-configuration --bucket mybucket --lifecycle-configuration file://s3bucket-lifecycle-policy.json

Shouldn't be hard to implement for s3cmd :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants