Backup your Database¶
How to Dump the Database¶
This needs to be done from the production machine:
cd /var/www/apps/my_app
rake db:dump PASS_PROMPT=true ZIP=true VERBOSE=true CLEAN=true
How to Copy the Database Dump to local machine¶
This needs to be done from the machine where the want to copy the dump file to via rsync + ssh
rake rsync:db DBHOST=myhost.com REMOTE_PATH=/var/www/apps/my_app/schema/dumps VERBOSE=true RAILS_ENV=production
How to Load the Database Dump into MySQL¶
This needs to be done from the machine where you want to import the dump file.
You will actually have to supply the file name unless you are dumping and importing from equivalent environments, i.e. 'production' => 'production' or 'development' => 'development'.
So if you are dumping production and importing into development, you need to specify the FILE parameter. You'll need to at least modify the date in the example below:
rake db:load PASS_PROMPT=false FILE=production-data-2008-08-08.sql.gz VERBOSE=true