3. Import Database Backup¶
If you haven't already done so as a part of the "plan" phase, take a backup of the old installation's database.
Of course this is useful as a safety measure, but for parallel upgrades we mainly do this so that we can test our database migrations on the new installation with semi accurate data. We'll take another backup later once the old server is stopped for the purpose of actually restoring the database with up-to-date data.
Take Database Backup¶
If you've granted external access to the database, the easiest way to backup the database would be to use mysqldump from your local machine.
mysqldump -h <database-server-ip> openboxes > openboxes.sql
For example:
mysqldump -h openboxes.server.com openboxes > openboxes.sql
Or if you don't have your credentials configured in ~/.my.cnf
mysqldump -u root -p -h openboxes.server.com openboxes > openboxes.sql
A more secure way to perform the backup (and this could be basis for a cron job).
Connect to database server¶
ssh <database-server-ip>
For example:
ssh openboxes.server.com
Generate a backup¶
mysqldump openboxes > openboxes.sql
Or if you don't have your credentials configured in ~/.my.cnf
mysqldump -u root -p openboxes > openboxes.sql
Copy the backup to somewhere safe¶
scp openboxes.sql <backup-server-ip>:<backup-directory>
For example:
scp openboxes.sql backup.server.com:/backup/directory/openboxes.sql
You might elect to convert your backup script to a cron job that will run on regular intervals to take periodic backups.
In that case, you can simply wait for the cron to run, or trigger it manually to take a new backup.
Tip
When configuring your cron job, it is recommended that you specify the credentials in ~/.my.cnf so that you don't need to enter them (in plain text) in the commands of your cron scripts. See the following regarding MySQL client passwordless access
Restore Database Backup¶
Now that you have a backup of the old database, take that backup and upload it to the database in your new installation.
Todo