Skip to content

Instantly share code, notes, and snippets.

@knoxjeffrey
Created October 23, 2018 23:20
Show Gist options
  • Save knoxjeffrey/bc75057e800cac4b88075a6b22de4cda to your computer and use it in GitHub Desktop.
Save knoxjeffrey/bc75057e800cac4b88075a6b22de4cda to your computer and use it in GitHub Desktop.
Pull media from specified staging to production
# rake media:staging_to_production
# eg. rake media:staging_to_production
namespace :media do
desc 'Pull media from specified staging to production'
task :staging_to_production do
ssh_staging = Rails.application.credentials[:staging][:ssh]
ssh_staging_port = Rails.application.credentials[:staging][:ssh_port]
media_staging_remote = Rails.application.credentials[:staging][:media_remote]
media_production_remote = Rails.application.credentials[:production][:media_remote]
puts 'Copying media from staging to production...'
system "ssh #{ssh_staging} -t -p #{ssh_staging_port} sudo cp -rp #{media_staging_remote}/current/public/uploads/store/. #{media_production_remote}/current/public/uploads/store"
puts 'Done!'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment