Last active
December 10, 2015 21:38
-
-
Save blasterpal/4496287 to your computer and use it in GitHub Desktop.
Use fog to grab a file from S3 and save locally on server. Useful for transferring large backups from server to server where network prevents direct communication.
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 'fog' | |
| # Fetch and save backup on TARGET | |
| storage = Fog::Storage.new({:provider => 'AWS', :aws_access_key_id => ENV['AWS_KEY'], :aws_secret_access_key => ENV['AWS_SECRET']}) | |
| dir = storage.directories.get('<YOUR DIR>') | |
| file = dir.files.get "<S3 PATH TO FILE>" | |
| output = File.new "<LOCAL FILE PATH>", "w" | |
| output.write file.body | |
| output.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment