Reputation: 4391
The production server that hosts my rails app is being wiped and started again, as a result i will need to transfer my rails app onto the new system. The source isnt a problem i can just pull down from git again but the database is another matter. I could install phpmyadmin or something similar to access the database but i was wondering if there was something in rails (possibly a rake task) that would let me dump the current database and then import it onto a new server.
Upvotes: 1
Views: 611
Reputation: 8841
If it is a recurring task, you could also put that into a rake task under lib/tasks:
namespace :db do
desc "Dump database"
task :dump => :environment do
exec "mysqldump -u root -p databasename > database.sql"
end
desc "Restore database"
task :restore => :environment do
exec "mysql -u root -p newdatabasename < database.sql"
end
end
Upvotes: 5
Reputation: 11079
You don't need Rails or PHPMyAdmin for this. Assuming you're using MySQL, simply ssh to your server:
mysqldump -u root -p databasename > database.sql
Then on the other system:
mysql -u root -p newdatabasename < database.sql
Easy, huh?
Upvotes: 7