Created
September 28, 2011 04:00
-
-
Save steveh/1246956 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "pp" | |
| namespace :fog do | |
| task :setup => :environment do | |
| $src_store = Fog::Storage.new( | |
| :provider => "AWS", | |
| :aws_access_key_id => Localist::Config[:amazon][:access_key_id], | |
| :aws_secret_access_key => Localist::Config[:amazon][:secret_access_key], | |
| :region => "us-west-1", | |
| ) | |
| $dst_store = Fog::Storage.new( | |
| :provider => "Rackspace", | |
| :rackspace_username => Localist::Config[:rackspace][:username], | |
| :rackspace_api_key => Localist::Config[:rackspace][:api_key], | |
| ) | |
| end | |
| task :migrate => :setup do | |
| buckets = { | |
| "localist-ads-production" => "ads-production", | |
| "localist-assets-production" => "assets-production", | |
| } | |
| buckets.each_pair do |src_bucket, dst_bucket| | |
| src_dir = $src_store.directories.detect{ |dir| dir.key.split(/\./).first == src_bucket } | |
| dst_dir = $dst_store.directories.detect{ |dir| dir.key.split(/\./).first == dst_bucket } | |
| src_dir.files.each do |src_file| | |
| dst_file = dst_dir.files.head(src_file.key) | |
| unless dst_file | |
| dst_file = dst_dir.files.create({ | |
| :key => src_file.key, | |
| :body => src_file.body, | |
| :public => true | |
| }) | |
| end | |
| pp dst_file | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment