User Guide · for DomainMOD 5.0.0
Backup & Restore
As of v4.14, DomainMOD has a Backup & Restore utility. This feature enables you to perform complete backups and restores of your DomainMOD database. This allows you to export your entire system in a single file so that it can easily be backed up and/or restored, which is helpful if you want to back up your data regularly, move DomainMOD to a new server, or change your installation method.
This process backs up the data saved in your database. It doesn't include settings stored outside the database, such as your database connection information and any MFA keys in use, which are in your /_includes/config.inc.php file (for Docker installs, in your .env file, Compose file, or container settings). Back them up too and keep them somewhere private, but not in the same place as your database backups.
A backup includes your saved registrar passwords, API keys, and Data Warehouse server tokens as they're stored, so keep your backup files private. With an MFA key set, they're encrypted (see Encrypting Saved Credentials), apart from values that haven't been encrypted yet, such as ones saved before the key was set, ones a restore brought back unencrypted, and ones that Stop Encrypting stored without encryption or that were saved after it. While encryption is on, the daily System Cleanup task encrypts them, or you can run Encrypt Saved Credentials right away. Backup & Restore says when some are stored without encryption, and Administration -> MFA Key counts the encrypted ones.
Backups don't include the MFA key that encrypts users' MFA secrets and saved credentials, so keep the key with your backups' records, but not in the same place as the backups. When a key is set, Backup & Restore shows its key ID and how many values each key opens. As of v5.0.0, each backup also lists the key IDs its values need, and a restore says which of them this installation doesn't have. Keep every key a backup you keep needs, labelled with its ID. For a backup from before v5.0.0, or one whose restore reports values with an unverified key ID or MFA secrets with an unknown key, keep every key the installation (or any installation its data was restored from) used before the backup was taken.
A restore never changes which key the installation uses. After a restore, DomainMOD says how many users' MFA secrets and saved credentials can't be read with its key, and what to do about them (see Security and MFA).
As of v5.0.0, a Before You Back Up checklist at the top of Backup & Restore shows what to have in hand before you rely on a backup, worked out from your data each time the page loads. It shows whether an MFA key is set to protect MFA secrets and saved credentials, and its key ID when it is. It also shows how many active users with MFA haven't confirmed saving their recovery codes or have none left, naming the account with the username admin if it's one of them, since no one else can reset its MFA. Last come a reminder to keep backups private and the version a restore needs. Items that are done have a green check, and items to deal with have a warning.
Note
Backups are created in PHP's temporary folder, which must be outside your web root, and are deleted as soon as they've been sent to your browser. Restores are refused if PHP's upload folder (upload_tmp_dir) is inside your web root. If you're unsure how to check this, your web hosting provider should be able to assist you.
Backup
To back up your DomainMOD database:
-
Login to DomainMOD as an administrator
-
Navigate to Administration -> Backup & Restore
-
In the Back Up section, click the Back Up Entire Database button
-
At this point you will be prompted to download the file domainmod-backup.sql, which contains a copy of your entire database
Restore
Warning
Before restoring your DomainMOD database, ensure that you're restoring a database that is of the same version as the software that you're restoring it to. For example, if you were using DomainMOD v4.14 when you backed up your database, you must restore that database to an installation of DomainMOD v4.14.
On v5.0.0 and later, before you restore a backup that needs a key this installation doesn't have (see above for which keys a backup needs), set that key as the previous key, keeping the current key as it is (or as the current key if this installation has none), then restart as Changing the Key describes, so the running installation uses it. The values that key encrypted can then be read as soon as the restore finishes, so those users can sign in with their authenticator app. If a backup needs more than one missing key, see Security and MFA. If a previous key is already set, check on Administration -> MFA Key whether it still opens any saved values, and whether the backup lists its key ID, before you replace it. A backup from before v5.0.0, or one that counts values with an unknown key, can also need keys it doesn't list (see above).
Restoring on v4.27.0
v4.27.0 has no previous key. After the restore finishes and before anyone signs in again, set the backup's key as the current key and restart as Changing the Key describes. Only one key can be set, so users whose MFA secrets need another key will need a recovery code or an administrator's reset. Another administrator can't reset the account with the username admin, so if it needs another key, set that key instead, or keep ready a recovery code it still had unused when the backup was made.
To restore your DomainMOD database:
-
Login to DomainMOD as an administrator
-
Navigate to Administration -> Backup & Restore
-
In the Restore section, click the Choose File button and then select the domainmod-backup.sql file that you want to restore
-
Click the Restore Entire Database button
-
Once the restore is complete, you're signed out of DomainMOD, and can then sign in with the accounts in the restored data.
As of v4.27.0, restores need DomainMOD's temp folder to be writable by the web server. When you restore a backup, the Change History becomes the backup's own.
If a Restore Doesn't Finish
If a restore stops part-way (for example, if the server times out), DomainMOD stays closed until it's finished. An administrator can open Administration -> Backup & Restore and click Finish Restore, or run php restore.php --recover in DomainMOD's folder on the server, as the web server's user (use this if you can't sign in). The cron job can also finish it when it runs cron.php from the command line or with a Task Scheduler Key, and then logs any warning in the server's error log. Finishing a restore doesn't redo the import, so if DomainMOD or the error log says the database may be partly restored, restore a complete backup before going on.
Restoring a Large Backup
If a backup is too large to upload, you can restore it on the server instead. Keep the backup file in a private folder outside your web root. Stop the cron job, then run this in DomainMOD's folder as the web server's user. --temp-dir is a private folder outside your web root that the web server's user can write to, where a copy of the backup is kept during the restore. Start the cron job again once the restore has finished.
php restore.php /path/to/private/folder/domainmod-backup.sql --temp-dir=/path/to/private/folder
Migrating
Warning
Before migrating it's strongly recommended that you back up your DomainMOD installation directory and database. If something goes wrong during the migration process there may be no way to recover your data, and having a backup of your installation directory and database will allow you to easily restore your data.
The Backup & Restore instructions can be found here.
To migrate your DomainMOD installation from one server to another:
-
[Old Server] Upgrade to the newest version of DomainMOD
-
[Old Server] Export a copy of your DomainMOD database using the above Backup feature, and note your MFA key (
$secret_keyin config.inc.php, orDOMAINMOD_SECRET_KEYfor Docker) if you've set one, and your previous key ($previous_secret_key, orDOMAINMOD_PREVIOUS_SECRET_KEYfor Docker) if one is set. Keep them with the backup's records, but not in the same file or place. -
[New Server] Download and install the newest version of DomainMOD, with the same MFA key (and the same previous key, if you noted one), so the saved credentials and MFA secrets in the backup can be read
-
[New Server] Login to DomainMOD and navigate to Administration -> Backup & Restore
-
[New Server] In the Restore section, click the Choose File button and then select the domainmod-backup.sql file that you want to restore
-
[New Server] Click the Restore Entire Database button
-
[New Server] Once the restore is complete you will automatically be logged out of DomainMOD. You should now be able to login using the accounts that you just restored.
-
That's it! DomainMOD has now been migrated to your new server.