还原: Difference between revisions

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
Line 37: Line 37:
  * Reprendre le fichier archive (fichier zip par exemple) du répertoire documents et en extraire l'arborescence dans le répertoire documents d'une nouvelle  
  * Reprendre le fichier archive (fichier zip par exemple) du répertoire documents et en extraire l'arborescence dans le répertoire documents d'une nouvelle  
   installation de dolibarr ou dans le répertoire documents de cette installation ('''''chemin du répertoire des documents''''').
   installation de dolibarr ou dans le répertoire documents de cette installation ('''''chemin du répertoire des documents''''').
此目录必须为空(否则,可以清除其内容)。 您所要做的就是将备份目录的内容从旧文件复制到该目录中。
此目录必须为空(否则,可以清除其内容)。 您所要做的就是将备份的目录内容复制到该目录中。
=Step 3 - Restore the database=
=步骤 3 - 还原数据库=
==MySql==
==MySql==
Copy the backup dump file into the same directory than the command '''mysql'''.
在非Linux平台上,如果DOS无法识别'''mysql'''命令,这意味着PATH变量未指向 mysql.exe 所在的目录。 它必须:


If your backup file was a compressed archive, unzipping the file before might be required:
* 在系统变量PATH中添加mysql.exe文件所在的目录;
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'''.
* 将备份转储文件复制到mysql.exe文件所在的目录;


Choose the import method.
如果备份文件是压缩文件,请先解压缩该文件。
 
例如,一个名为 mysqldump_dolibarr_2.7.0_200812021800.sql.bz2 的已压缩备份文件必需被解压缩为文件                      mysqldump_dolibarr_2.7.0_200812021800.sql(Linux平台启动命令bunzip myfile.bz2,Windows平台启动命令 7zip)。
 
在新安装的Dolibarr上,使用管理员帐户登录,然后前往菜单 '''主页 / 管理工具 / 还原''' 。
 
选择导入MySQL的方法。
 
然后,Dolibarr在命令行中显示一个命令,该命令带有隐藏密码,以执行数据库还原。单击“显示完整命令”以获得未隐藏密码的完整命令。
 
例如,我们将有:


Dolibarr offers a command line to launch to restore the database. Click on "Show the full command".
For example, you will have :
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mysql mydatabase -h localhost -u databaseuser -pdatabasepass < mybackupfile.sql
mysql mydatabase -h localhost -u databaseuser -pdatabasepass < mybackupfile.sql
</syntaxhighlight>
</syntaxhighlight>


Open a command line shell (DOS Command line with Windows or a Shell terminal with Linux).
打开命令行shell(Windows平台的DOS命令、Linux平台的shell终端...)。
Go into the directory where command '''mysql''' and your backup file is stored.
 
Launch the command provided previously.
前往保存着要还原的备份文件和命令'''mysql'''.exe的目录。 运行先前提供的命令,知道每个空格(或缺少空格)、"—"或"<"是必需的,否则将产生语法错误。





Revision as of 06:53, 12 September 2023

本页介绍如何还原Dolibarr的备份(如在硬盘被格式化后)。要了解如何进行完整备份,请参阅 备份 页面。

前提条件

要在干净的环境中进行一个完整的还原,必需:

  • 拥有数据库的完整备份(例如,使用mysql的工具mysqldump把MySQL或MariaDb数据库备份到转储文件中)。
  • 拥有 documents 目录中所有文件的完整备份。
  • 拥有用于访问已备份的 Dolibarr 的管理员用户的登录名和密码。

步骤 1 - 重新安装 Dolibarr 软件

如果您已经卸载了Dolibarr或因为使用新服务器而尚未安装Dolibarr,则应先安装Dolibarr,使其拥有一个新的干净的数据库。

需要使用与以前相同类型的数据库(MySQL、PostgreSQL...)。

您可以选择任何的 Dolibarr发行版(Dolibarr、DoliWamp、DoliMamp、DoliDeb或任何其他的Linux发行版...)进行安装;但是,它必须与备份期间使用的版本(vX.Y)完全相同(如果您想升级版本,建议稍后再进行)。

注意:如果备份是使用 Dolibarr 进行操作的,则备份的Dolibarr版本信息包含在数据库备份文件的名称中。

步骤 2 - 还原文档

在新安装的Dolibarr上,使用管理员帐户前往菜单 主页>管理工具>还原 。

Dolibarr将通过以下消息向您显示文档文件目录的存储位置:

Pour restaurer une sauvegarde de Dolibarr, vous devez:

* Reprendre le fichier archive (fichier zip par exemple) du répertoire documents et en extraire l'arborescence dans le répertoire documents d'une nouvelle 
  installation de dolibarr ou dans le répertoire documents de cette installation (chemin du répertoire des documents).

此目录必须为空(否则,可以清除其内容)。 您所要做的就是将备份的目录内容复制到该目录中。

步骤 3 - 还原数据库

MySql

在非Linux平台上,如果DOS无法识别mysql命令,这意味着PATH变量未指向 mysql.exe 所在的目录。 它必须:

  • 在系统变量PATH中添加mysql.exe文件所在的目录;
  • 将备份转储文件复制到mysql.exe文件所在的目录;

如果备份文件是压缩文件,请先解压缩该文件。

例如,一个名为 mysqldump_dolibarr_2.7.0_200812021800.sql.bz2 的已压缩备份文件必需被解压缩为文件 mysqldump_dolibarr_2.7.0_200812021800.sql(Linux平台启动命令bunzip myfile.bz2,Windows平台启动命令 7zip)。

在新安装的Dolibarr上,使用管理员帐户登录,然后前往菜单 主页 / 管理工具 / 还原 。

选择导入MySQL的方法。

然后,Dolibarr在命令行中显示一个命令,该命令带有隐藏密码,以执行数据库还原。单击“显示完整命令”以获得未隐藏密码的完整命令。

例如,我们将有:

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

打开命令行shell(Windows平台的DOS命令、Linux平台的shell终端...)。

前往保存着要还原的备份文件和命令mysql.exe的目录。 运行先前提供的命令,知道每个空格(或缺少空格)、"—"或"<"是必需的,否则将产生语法错误。


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.

相关视频

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