备份: Difference between revisions

Jump to navigation Jump to search
Line 75: Line 75:
''备选方案'':默认方法 '''MySQL转储(mysqldump)'''需要您有权限访问和运行服务器上的二进制文件mysqldump,并使用消耗大量内存的默认设置。 如果您使用的是共享主机,并且内存不足(这通常会导致空白页面),您可以尝试从Dolibarr 16.0开始选择导出选项“在低内存模式下转储”。  如果您的主机禁止使用mysqldump程序,您也可以尝试另一种方法 '''MySQL Dump (php)''' 。此方法不能保证100%,因此请先自己尝试,先备份,然后在本地非生产服务器上还原,以检查您的数据是否被正确备份。
''备选方案'':默认方法 '''MySQL转储(mysqldump)'''需要您有权限访问和运行服务器上的二进制文件mysqldump,并使用消耗大量内存的默认设置。 如果您使用的是共享主机,并且内存不足(这通常会导致空白页面),您可以尝试从Dolibarr 16.0开始选择导出选项“在低内存模式下转储”。  如果您的主机禁止使用mysqldump程序,您也可以尝试另一种方法 '''MySQL Dump (php)''' 。此方法不能保证100%,因此请先自己尝试,先备份,然后在本地非生产服务器上还原,以检查您的数据是否被正确备份。


警告:一些用户报告说,当启用压缩时,某些主机的备份有时不完整(缺少一些表)。虽然无法重现此问题,但请记住通过查看.sql文件的内容来检查备份的内容,该文件应以样式行结尾。
警告:一些用户报告说,当启用压缩时,某些主机的备份有时不完整(缺少一些表)。虽然无法重现此问题,但请记住通过查看.sql文件的内容来检查备份的内容,该文件的结尾行应是如下样式:


<syntaxhighlight lang="sql">
<syntaxhighlight lang="sql">
Line 83: Line 83:
或者,如果您想万无一失,就不要启用压缩。
或者,如果您想万无一失,就不要启用压缩。


===Using mysqldump===
===使用 mysqldump===
If you prefer a manual mode, you can also use the backup tool designed for your database.
如果您更喜欢手动模式,可以直接使用数据库提供的备份工具。
With Mysql, the command to backup your database into a file is :
 
在MySQL中,将数据库备份到文件的命令是:
 
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mysqldump -u user -pyourpass --result-file=mysqldump_databasename_version_date.sql databasename
mysqldump -u user -pyourpass --result-file=mysqldump_databasename_version_date.sql databasename
</syntaxhighlight>
</syntaxhighlight>
where :


*''user'' is MySQL user that Dolibarr use to connect to database,
其中:
*''yourpass'' is password of MySQL account user (warning, no space between the p and yourpass),
 
*''databasename'' is the name of Dolibarr database.
*''user'' 是Dolibarr用于连接到数据库的MySQL特权用户,
*''yourpass'' 是MySQL用户帐户的密码(注意,p和<syntaxhighlight lang="bash">
mysqldump -u user -pyourpass --result-file=mysqldump_databasename_version_date.sql databasename
</syntaxhighlight>之间没有空格),
*''databasename'' 是数据库服务器的名称或IP。


Those informations (user, password and database) are available into your configuration file ''dolibarrdir/htdocs/conf/conf.php''
这些信息(用户、密码和数据库)可在配置文件 ''dolibarrdir/htdocs/conf/conf.php'' 中找到 。


The result file ("dump file"), is called mysqldump_databasename_version_date.sql where
生成的结果文件(称为"转储文件")名为 mysqldump_databasename_version_date.sql ,其中


*''version'' is the dolibarr version (ex: 3.7).
*''version'' 是 dolibarr 的版本号(如:3.7)。
*''date'' can be replaced with a date, recommanded format is YYYYMMDD, with YYYY the year (ex. 2011), MM is month number (ex. 05) and DD is day in month (ex. 18).
*''date'' 可以被替换为一个日期,建议格式为YYYYMMDD,其中YYYY表示年份(例如,2011年),MM为月份编号(例如05),DD为在一个月中的哪一天(例如。18)。


With value used as example, we will get a dump file called ''mysqldump_databasename_3.7_20110518.sql.''
使用上例的值,转储文件将被命名为 ''mysqldump_nombase_3.7_20110518.sql。''




If you want to have your file compressed (compressé) :
如果您想压缩您的文件,则使用如下命令:
 
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_version_date.bz2
mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_version_date.bz2
</syntaxhighlight>
</syntaxhighlight>
Dump file will be generated with a bzip compressed format.


'''Example:'''
以这种方式生成的转储文件将被直接压缩为 bzip 格式。
 
'''示例:'''
 
在Linux上,要在每天1:30定期备份到文件 mysqldump_databasename_DD.sql.bz2 中,您可以将以下内容添加到cron文件中:


With Linux, to make a regular backup at 1:30 each day into file mysqldump_databasename_DD.sql.bz2, you can add this into your cron file:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
30 1 * * * mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_`date +%d`.sql.bz2
30 1 * * * mysqldump databasename -h host -u user -pyourpass -l --single-transaction -K --add-drop-table=TRUE --tables -c -e --hex-blob --default-character-set=utf8 | bzip2 > mysqldump_databasename_`date +%d`.sql.bz2
</syntaxhighlight>
</syntaxhighlight>


===Using phpMyAdmin===
===使用 phpMyAdmin===


Do not use phpMyAdmin to save your database ! phpMyAdmin generates some dump files, but if you used default option, you won't be able to restore it. You must enable one specific option for you to be able to restore your backup later on (if you forgot to do so and already have a backup that you want to restore, please read the note about FOREIGN_KEY_CHECKS below).
您也可以使用phpMyAdmin备份数据库,但'''必须'''启用一个选项,以便以后可以使用备份来恢复(如果您忘记这样做,请阅读下面关于foreign-key-checks的说明)。


In phpMyAdmin, click on the tab '''Export''', then select your Dolibarr's database/tables (depending whether you are in multi-database view or tables view), and then '''enable''' the option '''Disable foreign key checks''', also check that the output will be SQL, and then you can validate your export. Also, not that, even with this option, backup is NEVER guaruanted with phpMyAdmin and is OFTEN useless. The only secured method is to use mysqldump (from Dolibarr or manually. See the two previous chapters).
在phpMyAdmin中,单击'''导出'''选项卡,其次选择Dolibarr数据库或Dolibarr表(取决于您所在的窗口-数据库视图或表视图),并选中'''禁用外键检查''',同时检查结果是否为SQL格式,最后可以验证导出。


===Using another Third-Party Tools===
注意:如果您使用默认选项,则无法使用备份来恢复。此外,即使有了这个选项,备份也永远不会被 phpMyAdmin保护,而且经常是无法使用的。唯一安全的方法是使用 mysqldump(从 Dolibarr 或手动。请参阅前两章)。


You can also use third-party database backup softwares, like php scripts that you can upload on your server (such as db2SQL by Howard Yeend or BigDump), or also use database designer/workbench softwares which generally offer to remotely connect to your database and allow you to make a full backup (along to remotely manage your database).
===使用其它第三方工具===


您也可以使用第三方的数据库备份软件,例如可以上传到服务器上的PHP脚本(如 db2SQL by Howard Yeend 或BigDump),或者使用数据库设计器/工作台软件,它们通常提供远程连接到数据库的能力,并允许您执行完整备份(远程管理数据库功能)。


----
----
714

edits

Navigation menu