Restores

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search

This page describe how to restore a backup of Dolibarr (for example after formatting your hard disk). To know how to do a complete backup, see page Backup.

Prerequisites

For a complete restore on a clean environment, we suppose that you :

  • Have a backup of your database (into a dump file, done with mysqldump tool for example if you used a MySQL or MariaDb database).
  • Have a backup of your document files directory.
  • You know a login of an admin user you used before, when old Dolibarr backup was done.

Step 1 - Reinstall Dolibarr software

If you have uninstalled Dolibarr or not yet installed because you are on a new server, you must install Dolibarr as if you want to use it with a new clean database.

Be carefull to choose the same database type than before (Mysql, PostgreSQL...).

You can install any Dolibarr distribution of your choice (Dolibarr, DoliWamp, DoliMamp, any other Linux distribution...), however it must be exactly the same version (vX.Y) than the one used to make the backup. The version may be included in the file name of the database backup.

Step 2 - Restore documents

On your new installed Dolibarr, go with an administrator user in the menu Home / System Tools / Restore.

Dolibarr will show you where your documents files must be stored. This directory must be empty (if not you can purge it). All you have to do then is to copy content of your saved directory of old documents files into this directory.

Step 3 - Restore the database

MySql

Copy the backup dump file into the same directory than the command mysql.

If your backup file was a compressed archive, unzipping the file before might be required: For example, a bzip archive backup named mysqldump_dolibarr_2.7.0_200812021800.sql.bz2 must be uncompressed to mysqldump_dolibarr_2.7.0_200812021800.sql (Launch bunzip myfile.bz2 under Linux, or use 7zip under Windows).

On your new installed Dolibarr, go with an administrator user in the menu Home / System Tools / Restore.

Choose the import method.

Dolibarr offers a command line to launch to restore the database. Click on "Show the full command". For example, you will have :

mysql mydatabase -h localhost -u databaseuser -pdatabasepass < mybackupfile.sql

Open a command line shell (DOS Command line with Windows or a Shell terminal with Linux). Go into the directory where command mysql and your backup file is stored. Launch the command provided previously.


Alternative: you can also use phpMyAdmin Import tab to restore your backup file (normally you don't have to check any particular option, but your backup file needs to disable foreign_key_checks, see below). Also this method can not be guaranted and may failed in some cases.


Troubleshooting

Warning.png ERROR 1005 (HY000) at line 20: Can't create table `dolibarr`.`llx_accounting_account` (errno: 150 "Foreign key constraint is incorrectly formed")

=> If you have such error, you mut manually delete the table llx_accounting_account and llx_accounting_system, before trying again.


Warning.png If you have error with foreign keys, check that your sql backup file disable foreign keys prior to restoring, else your backup won't be restorable because of foreign keys clashing!

Eg: Add FOREIGN_KEY_CHECKS in headers and footers:

-- SQL Dump
-- Server version: 5.5.8

SET FOREIGN_KEY_CHECKS=0;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

CREATE TABLE IF NOT EXISTS `llx_accountingaccount` (

INSERT INTO ...

CREATE TABLE ...

INSERT INTO ...

...

SET FOREIGN_KEY_CHECKS=1;

PostgreSql

A procedure similar to MySQL but with pg_restore.

En verysmall.png Page waiting to complete. To complete, create an account, go back and clic on "Modify".
Fr verysmall.png Page en attente d'être complété. Pour compléter, créez un compte, revenez et cliquez sur "Modifier".
Es verysmall.png Página a completar. Para completarla, cree una cuenta, vuelva a la página y haga clic en "editar"
De verysmall.png Seite wartet auf Vervollständigung. Um zu helfen, erstelle ein Konto, gehe zurück und klicke auf "Bearbeiten".
Cn verysmall.png 待完成,欲帮助完成,注册帐号,点击“编辑"
Jp verysmall.png ページは未完成の状態です。完成させるにはアカウントを作成し、ページに戻って「編集」をクリックして下さい。

Step 4 - Use your restored Dolibarr

After command is finished, you can go on Dolibarr logon. Now you must use a login account that was existing when the backup was done.

Related videos

Data restoration on a Docker installation: (vocal in french but subtitles are available and review in this language)