s3_sync

Securely sync (upload and download) files with Amazon Simple Storage Service (s3).

Specify credentials, file names, and other options during configuration.

Installation

Add this line to your application's Gemfile:

gem 's3_sync'

And then execute:

$ bundle

Or install it yourself as:

$ gem install s3_sync

Usage

Configuring

Configure the gem to use the same options when uploading and downloading.

S3Sync.configure do |config|
  config.key_id = "mykey123"
  config.key_secret = "secret456"
  config.region = "us-east-1"
  config.bucket = "my-backups"
  config.secret_phrase = "my-s3cr3t"
  config.files = [
    File.join(Dir.home,".bash_profile"),
    File.join(Dir.home,".gitconfig"),
    File.join(Dir.home,".ssh","config")
  ]
  config.downloads_dir = File.join(Dir.home,"Desktop","my-s3-downloads")
end

Configuration Options

attribute name description default value
key_id The s3 user's Access Key Id. N/A
key_secret The s3 user's Access Key Secret. N/A
region The s3 region. N/A
bucket The s3 bucket (top-level directory) name. N/A
secret_phrase The phrase to use when encrypting and decrypting files. N/A
files A list of local file paths to be synced. N/A
downloads_dir A staging directory to house downloaded files. File.join(Dir.home,"Desktop","s3-downloads")

Uploading

Upload files from your computer to s3.

S3Sync::Upload.new

The uploads bucket gets created automatically, and can be configured with config.bucket.

Downloading

Download files from s3 to your computer.

S3Sync::Download.new

Files are downloaded to a staging directory, which can be configured with config.downloads_dir. The staging directory helps mitigate the risk of accidentally over-writing local files.

Prerequisites

Create an AWS Identity and Access Management (IAM) user and obtain its Access Key Id and Secret Access Key.

Create an AWS IAM group.

Create an AWS IAM policy with the arn:aws:iam::aws:policy/AmazonS3FullAccess permission set.

Attach the policy to the group.

Add the user to the group.

Contributing

Browse existing issues or create a new issue to communicate bugs, desired features, etc.

After forking the repo and pushing your changes, create a pull request referencing the applicable issue(s).

Installation

Check out the repo with git clone [email protected]:s2t2/s3-sync-ruby.git, and cd s3-sync-ruby.

After checking out the repo, run bin/setup to install dependencies.

Testing

Run bundle exec rake or bundle exec rspec spec/ to run the tests.

You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Releasing

Update the version number in version.rb, then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.