Table of Contents

Backup & Restore

Creating the backup

To create the dump, use this command from your shell/command-line:

mysqldump -uusername -ppassword -–default-character-set=utf8 -N database > backup.sql

Where:

The above command is very efficient and takes very little time to execute. Notice that the character set specified is UTF8. Even if your database is encoded in another character set, I recommend using UTF8 as I found it to work fine with any database without having to make any guesses.

The Nextcloud database is using 4-byte character encoding for emoji. Backup and restore should use: –default-character-set=utf8mb4 instead!

Restoring the Backup

Restoring a database from a backup file is pretty easy. First, empty the database to avoid error messages, then run this command:

mysql -uusername -ppassword -–default-character-set=utf8 database < backup.sql

Where: username is your MySQL username. password is your MySQL password. database is the name of the database you want to restore. backup.sql is the full path to the mysql dump file that you want to restore from. You can also use the above command to copy your database from one server to another. This command is very efficient as well and executes in a very short time.

The Nextcloud database is using 4-byte character encoding for emoji. Backup and restore should use: -–default-character-set=utf8mb4 instead!