Safely Backup and Restore a ModernBill MySQL Database

Before making any major changes to your system, including upgrades or any direct database work, we strongly recommend that you back up your database. The following is a method for accomplishing this.

Backing up the Database

The process of backing up the database involves using the command mysqldump. The steps are fairly typical, except that you need to ensure that the character set is UTF-8. To do that, the argument --default-character-set=utf8 may be passed to both mysql and mysqldump as demonstrated below:

  1. On the command line, move to the directory in where you would like to store the database. It is recommended that you store this some place that is not outside accessible, as your database contains a lot of sensitive data.
  2. Then run the following:

    mysqldump --default-character-set=utf8 -uusername database_name -p | gzip > dump.sql.gz

    where username is the username for the ModernBill database and database_name is the name of the ModernBill database.

  3. You will be prompted for your database password. Enter it, and a backup will be created in the current directory.

Restoring the database

You only need to restore the database if something went wrong while you were upgrading or making changes, and you need to "start over" from scratch.

  1. Navigate to the directory where you stored your database backup.
  2. From the command line, run the following:

    gunzip -c dump.sql.gz | mysql --default-character-set=utf8

If the character set encoding is not preserved properly, multibyte characters may be malformed on restoration. Symptoms of this problem include:

The language drop-downs and currency symbols can be fixed by loading locale.sql.gz (properly passing --default-character-set=utf8 to MySQL) available in the Misc. Downloads page of the Download Center.