PatrickLef / s3_cleanser

Small script for deleting old objects from a S3 bucket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clean out old objects from an AWS S3 bucket

INSTALL

Use bundler to install gems. E.g. to install in vendor

  bundle install --path vendor

Local

Copy settings file in conf dir.

cp config/settings.yml.erb to confif/setting.yml

Enter your AWS credentials and default host. E.g. of default host for Europe is s3-eu-west-1.amazonaws.com

Remote

A Capistrano stage file is provided. Edit

  • Address to server
  • User and path to SSH key

Use Capistrano to deploy. When running deploy:setup, a settings.yml will be created for you on the server.

  bundle exec cap aws deploy:setup

Check the setup

  bundle exec cap aws deploy:check

Install

  bundle exec cap aws deploy

Running S3 cleanser

s3_cleanser takes 3 arguments. 1 name of bucket 2 date. objects older than date will be deleted 3 marker. If you want to start with a specific marker. Useful when starting multiple s3_cleanser to delete objects in the same bucket.

Name of bucket and date are mandatory.

Delete objects in bucket my_test_bucket that were last modified before 2012-08-01

  bundle exec ruby s3_cleanser.rb my_test_bucket 2012-08-01

Same as above but start deleting objects that start with d

  bundle exec ruby s3_cleanser.rb my_test_bucket 2012-08-01 d

About

Small script for deleting old objects from a S3 bucket