数据备份

在iTop中,所有数据(包括上载的文档)都存储在MySql数据库中。因此,强烈建议定期安装数据库数据库。

集成备份

从iTop 2.1.0开始,管理员可以使用特殊菜单“计划的备份”:

https://www.itophub.io/wiki/media?media=2_7_0%3Aadmin%3Abackup-menu.png

此管理页面提醒您当前设置,并列出备份文件:

https://www.itophub.io/wiki/media?media=2_7_0%3Aadmin%3Abackup_page.png

计划的备份依赖于后台流程cron.php。参考后台任务 有关如何配置的更多信息。

立即单击备份!执行备份(无需确认):

https://www.itophub.io/wiki/media?media=2_7_0%3Aadmin%3Abackup_running.png

备份包含什么?

备份由单个zip文件组成。

它包含复原和应用所需的所有数据:

  • 配置(即配置文件itop-config.php)
  • 数据(即MySQL数据库的完整转储)
  • .xml增量文件

如果您在运行备份之后安装了新模块,则还原备份等同于卸载模块。如果希望将模块放回iTop中,请再次运行安装程序。

如果自从备份制成以来已经升级了iTop或任何模块,则不保证还原会正常进行。无论如何,再次运行安装程序更安全。

配置

可以在iTop配置文件的itop-备份部分中调整自动备份方案:

参数类型描述默认价值
mysql_bindirMySQL二进制文件的目录(如果不在“路径”中)。既用于计划备份,又用作REST服务的默认价值 
week_days必须执行自动备份的工作日(小写)的CSV列表周一周二周三周四周五
time基于24小时的时间,必须执行自动备份23:30
retention_count整型目标目录中将保留的备份文件数5
enabled布尔开启/关闭自动备份真正
file_name_format备份的名称(zip),仅用于计划的备份。支持以下占位符:__HOST__,__DB__,__SUBNAME__。时间信息可以基于PHP/strftime 规格。__DB__-%Y-%m-%d_%H_%M
itop_backup_incidentiTop的URL。如果备份失败,它将在此iTop中创建工单。 (此参数在2.5.2+中称为itop_root)如果为空或没有,则参数将使用当前的Itop APP_ROOT

要检查配置,请查看备份管理页面:配置配置将解释如何解释配置(或找到配置的问题)。

计划中的更改(包括禁用特性)将在变更发生之前的下一次计划备份时纳入账号。

当禁用计划的备份时,状况页面仍然报告配置,就好像它已被启用一样。

自订排程

自动调度的替代方法是实施您自己的调度,依靠提供的REST服务来执行备份或监视流程。

提供了文件备份。params.distrib来解释参数:

backup.params.distrib
 
# Parameters file for backup.php and check-backup.php
#
# Usage:
# backup.php --param_file=<this file>[,<another one>]
# or
# http://.../itop-backup/backup.php?param_file=<this file>[,<another one>]
#
# If a parameter is given both in the file and in the arguments,
# then the value given as argument is retained
#
# Note: most of the default values provided here should work fine
#       if you have created sample data with the setup program

# MySQL coming with Easy PHP (Windows)
mysql_bindir = C:\Program Files\EasyPHP-5.3.6.0\\bin
 
 
# Authentication
auth_user = admin
auth_pwd = admin
 
# Target file - path and filename (optional)
#
# Formatting rules:
# %Y-%m-%d => 2011-01-25... see PHP documentation of strftime()
# Placeholders:
#    __HOST__      MySQL server
#    __DB__        Database name
#    __SUBNAME__   Tables prefix
# 
backup_file = /var//__DB__-%Y-%m-%d
 
# Check thresholds (check-backup.php)
#
check_size_min = 20000 # bytes
check_size_reduction_max = 10 # percentage

# Ticket creation (check-backup.php)
#
# If the backup has failed, a ticket will be created
# This process relies on the SOAP service "CreateIncident"
#
# Root URL of an instance of iTop, into which the ticket will be created : config file param 'itop_backup_incident'
# Any of the above paramaters are mandatory
check_ticket_login = admin # must have the right to create an Incident Ticket
check_ticket_pwd = admin
check_ticket_title = Backup check failed
check_ticket_customer = Demo
check_ticket_service = Computers and peripherals
check_ticket_service_subcategory = Repair
check_ticket_workgroup = Hardware support
check_ticket_impacted_server = dbserver1.demo.com

默认情况下,mysql_bindir被获取到模块的配置中。如果在参数文件或命令行中指定了它,则该价值将具有优先权。另一方面,必须在参数文件或命令行中指定文件名。此外,必须指定文件名以及完整路径,或相对于当前目录。

关于check-backup.php:这是监控功用。必须在备份。php之后执行。它根据文件名规范验证文件是否确实存在。此外,它还旨在检测文件大小中的可疑变化。

check-backup.php要求您在配置参数itop_backup_incident(可以与要执行备份的iTop不同)所针对的iTop的安装上安装事件管理模块。

使用mysqldump创建备份

与以前的iTop版本一样,您仍然可以使用MySQL随附的mysqldump命令行功用创建自己的备份。

您可以使用以下mysqldump命令运行数据库的完整备份:

在Linux系统上:

/usr/bin/mysqldump --opt --default-character-set=utf8 --single-transaction --add-drop-database --user=<user> --password=<password> <DB> | gzip > <file>

On windows systems:

mysqldump.exe --opt --default-character-set=utf8 --single-transaction --add-drop-database --user=<user> --password=<password> <DB> > <file>

Where:

  • <user>是连接到MySQL的用户名称
  • <password>是相应的密码
  • <DB>是安装了iTop的数据库的名称
  • <file>是要生成的归档文件的名称

转储数据库的内容后,只需归档此转储和文件conf/production/config-itop.php即可保留iTop实例的完整映像。

  • 确保您以U-8 MB4(--default-character-set = u8mb4)格式导出数据,否则重音字符将丢失。
  • 选项--single-交易具有两个效果:由于所有表都在一个交易中导出,因此它产生一致的备份,并且为错误1449提供了一个变通方案(不存在定义器),如果您将交易和数据库已经从另一个系统重新导入或由不再存在的导出创建。

还原备份

对于复原,只需将备份重新放置为MySQL转储,并将复原重新放置为导入文件即可。

密码加密

如果数据模型使用具有可逆加密的密码字段,那么请确保在新旧系统上使用相同的加密算法:如果旧系统中存在mcrypt PHP扩展,则新系统中必须具有mcrypt扩展也一样如果mcrypt不存在,则也不能存在。

注意:用户帐户密码使用单向加密,不受mcrypt的影响。

在Linux上还原Windows备份(仅适用于iTop 1.x和2.0 beta 1)

如果您在Windows服务器上对iTop数据库进行备份,则所有数据库表名都将小写。在Linux上使用恢复时,表priv_internalUser将被拼写为priv_internaluser,这是不同的。在还原备份后无法登录iTop的情况下,请检查表的拼写是否正确。如果需要,将表重新分配给priv_internalUser。

从iTop 2.0 beta 2开始,这种情况将不再发生,因为所有表现在都是小写字母。

原贴链接:https://www.itophub.io/wiki/page?id=2_7_0%3Aadmin%3Abackup


Data backup

In iTop all the data (including the uploaded documents) are stored in the MySql database. Therefore it is highly recommended to have a database backup in place on a regular basis.

Integrated backups

Starting with iTop 2.1.0, a special menu “Scheduled backups” is available to the administrators:

https://www.itophub.io/wiki/media?media=2_7_0%3Aadmin%3Abackup-menu.png

This administration page reminds you the current settings, and lists the backup files:

https://www.itophub.io/wiki/media?media=2_7_0%3Aadmin%3Abackup_page.png

Scheduled backups rely on the background process cron.php. Refer to Background tasks for more information about how this is configured.

Click on Backup now! to perform a backup (no confirmation requested):

https://www.itophub.io/wiki/media?media=2_7_0%3Aadmin%3Abackup_running.png

What does a backup contain?

A backup is made of a single zip file.

It contains all the data that is necessary to restore the application:

  • The configuration (i.e. the configuration file itop-config.php)

  • The data (i.e. a full dump of the MySQL database)

  • The .xml delta file

If you have installed new modules after running a backup, restoring the backup is equivalent to uninstalling the modules. Run the setup again if you wish to have the modules back into the iTop.

If you have upgraded iTop or any of the modules since the backup has been made, then it is not garanteed that restoring will work fine. In any case it is safer to run the setup again.

Configuration

The automated backup scheme can be adjusted in the iTop configuration file, in the section itop-backup:

ParameterTypeDescriptionDefault Value
mysql_bindirstringDirectory of the MySQL binaries if not in the “path”. Used both for the scheduled backups and as the default value for the REST services 
week_daysstringCSV list of week days (lowercase) when the automated backup must be performedmonday, tuesday, wednesday, thursday, friday
timestring24h based time when the automated backup must be performed23:30
retention_countintNumber of backup files that will be kept in the target directory5
enabledboolSwitch on/off the automated backupstrue
file_name_formatstringName of the backup (zip), only for the scheduled backups. The following placeholders are supported: __HOST__, __DB__, __SUBNAME__. Timing information can be given based on PHP/strftimespecifications.__DB__-%Y-%m-%d_%H_%M
itop_backup_incidentstringURL of an iTop. It creates a ticket in this iTop if the backup fails. (This parameter was called itop_root in 2.5.2+)if empty or no parameter will use current itop APP_ROOT

To check the configuration, have a look the backup administration page: the configuration summary will explain how the configuration is interpreted (or report the issue if any is found)

Changes in the scheduling (including disabling the feature) will be taken into account at the next time a backup was planned before the change took place.

When the scheduled backups are disabled, the status page still reports the configuration as if it were enabled.

Custom scheduling

An alternative to the automatic scheduling is to implement your own scheduling, relying on the provided REST services to perform the backup or to monitor the process.

A file backup.params.distrib is provided to explain the parameters:

backup.params.distrib
 
# Parameters file for backup.php and check-backup.php
#
# Usage:
# backup.php --param_file=<this file>[,<another one>]
# or
# http://.../itop-backup/backup.php?param_file=<this file>[,<another one>]
#
# If a parameter is given both in the file and in the arguments,
# then the value given as argument is retained
#
# Note: most of the default values provided here should work fine
#       if you have created sample data with the setup program

# MySQL coming with Easy PHP (Windows)
mysql_bindir = C:\Program Files\EasyPHP-5.3.6.0\\bin
 
 
# Authentication
auth_user = admin
auth_pwd = admin
 
# Target file - path and filename (optional)
#
# Formatting rules:
# %Y-%m-%d => 2011-01-25... see PHP documentation of strftime()
# Placeholders:
#    __HOST__      MySQL server
#    __DB__        Database name
#    __SUBNAME__   Tables prefix
# 
backup_file = /var//__DB__-%Y-%m-%d
 
# Check thresholds (check-backup.php)
#
check_size_min = 20000 # bytes
check_size_reduction_max = 10 # percentage

# Ticket creation (check-backup.php)
#
# If the backup has failed, a ticket will be created
# This process relies on the SOAP service "CreateIncident"
#
# Root URL of an instance of iTop, into which the ticket will be created : config file param 'itop_backup_incident'
# Any of the above paramaters are mandatory
check_ticket_login = admin # must have the right to create an Incident Ticket
check_ticket_pwd = admin
check_ticket_title = Backup check failed
check_ticket_customer = Demo
check_ticket_service = Computers and peripherals
check_ticket_service_subcategory = Repair
check_ticket_workgroup = Hardware support
check_ticket_impacted_server = dbserver1.demo.com

By default, mysql_bindir is taken in the configuration of the module. If it is specified in the parameters file or the command line, then that value will have precedence. On the other hand, the file name must be specified either in a parameters file or in the command line. Moreover, the filename must be specified along with the full path, or relatively to the current directory.

About check-backup.php: This is a monitoring utility. It must be executed after backup.php. It verifies that the file does exist as per the filename specifications. Also, it aims at detecting suspicious changes in the file size.

check-backup.php requires that you have installed the Incident Management module on the installation of iTop targetted by the config parameter itop_backup_incident (which can be different than the iTop on which the backup is to be performed).

Creating your backups using mysqldump

As in previous versions of iTop, you can still create your own backups using the mysqldump command line utility which comes with MySQL.

You can run a full backup of the database using the following mysqldump command:

On Linux systems:

/usr/bin/mysqldump --opt --default-character-set=utf8 --single-transaction --add-drop-database --user=<user> --password=<password> <DB> | gzip > <file>

On windows systems:

mysqldump.exe --opt --default-character-set=utf8 --single-transaction --add-drop-database --user=<user> --password=<password> <DB> > <file>

Where:

  • <user> is the user name to connect to MySQL

  • <password> is the corresponding password

  • <DB> is the name of the database in which iTop is installed

  • <file> is the name of the archive file to produce

Once the content of the database is dumped, just archive this dump and the file conf/production/config-itop.php to keep a full image of your iTop instance.

  • Make sure that you export the data in UTF-8 MB4 (--default-character-set=utf8mb4) otherwise accentuated characters will be lost.

  • The option --single-transaction has two effects: it produces a consistent backup since all tables are exported in one transaction, and it provides a workaround for the error 1449 (definer does not exist) which may happen if you export a database that was already re-imported from another system or created by a no longer existing user.

Restoring a backup

To restore a backup just re-import the MySQL dump and restore the configuration file.

Passwords encryption

If the datamodel uses password fields with reversible encryption, then be sure that the same encryption algorithm is used on the new and old systems: if the mcrypt PHP extension was present on the old system, then the mcrypt extension must be present on the new system as well. If mcrypt was not present, it must not be present either.

Note: User accounts passwords use a one-way encryption and are not affected by the presence of mcrypt.

Restoring a Windows Backup on Linux (iTop 1.x and 2.0 beta 1 only)

If you backup the iTop database on a Windows server, all the database table names will be in lowercase. When restored on Linux, the table priv_internalUser will be spelledpriv_internaluser, which is different. In you cannot log into iTop after restoring a backup, check that the table is properly spelled. If needed, remane the table to priv_internalUser.

This should no longer occur starting with iTop 2.0 beta 2, since all the tables are now in lowercase.

标签:
由 superadmin 在 2020/08/25, 16:33 创建
    

需要帮助?

如果您需要有关XWiki的帮助,可以联系:

深圳市艾拓先锋企业管理咨询有限公司