为了确保备份数据的完整性,MySQL Enterprise Backup 提供了一个
validate
命令,用于在备份创建或传输到另一个系统后通过其数据页的校验和值来验证备份。
mysqlbackup [STD-OPTIONS]
[--backup-dir=PATH][--backup-image=IMAGE]
[MESSAGE-LOGGING-OPTIONS]
[PROGRESS-REPORT-OPTIONS]
[CLOUD-STORAGE-OPTIONS]
validate
validate
验证备份未损坏、未被截断或损坏。此操作验证备份中每个数据页的校验和值。
为了避免在损坏太严重的文件上花费过多的时间和资源,mysqlbackup 在发现超过二十个损坏的页面后停止验证 .ibd 文件,而是继续处理下一个文件。在这种情况下,该操作的摘要不会给出损坏页面的完整计数,而只会说 “至少有 20 个页面已损坏。”
该操作还具有以下限制:
对于任何备份目录,该操作只能验证其中的 InnoDB 数据文件(
ibdata*
和*.ibd
文件)。.frm
未检测到 备份目录中其他文件类型的问题(例如,文件损坏)。如果在备份过程中备份目录中有任何文件
.ibd
或.frm
文件丢失,或者备份完成后备份目录中的文件已被删除,则该validate
操作将无法检测到问题。如果备份目录因从其中的任何 .ibd 文件中删除或截断页面而损坏,则该
validate
操作将无法检测到该问题。
以下是验证备份目录的示例命令:
mysqlbackup -uroot --backup-dir=/logs/backupext validate
以下是用于验证备份映像的示例命令:
mysqlbackup -uroot --backup-image=/logs/fullimage.mi validate
以下是验证加密备份映像的示例命令以及成功验证的输出:
$ mysqlbackup –backup-image=/meb/backups/image.mbi --decrypt --key-file=/meb/enckeyfile validate 140219 11:22:44 mysqlbackup: INFO: Validating image ... /logs/img.bi 140219 11:22:44 mysqlbackup: INFO: Validate: [Dir]: meta 140219 11:22:45 mysqlbackup: INFO: Total files as specified in image: 44 mysqlbackup: INFO: datadir/tpch/tabnorm7.ibd Validated... mysqlbackup: INFO: datadir/tpch/tabnorm8.ibd Validated... mysqlbackup: INFO: datadir/tpch/tabnorm9.ibd Validated... ................ 140219 11:22:45 mysqlbackup: INFO: Validate operation completed successfully. 140219 11:22:45 mysqlbackup: INFO: Backup Image validation successful. mysqlbackup: INFO: Source Image Path = /logs/img.bi mysqlbackup completed OK!
这是标头中校验和不匹配的示例输出:
mysqlbackup: ERROR: Checksum mismatch. Computed checksum: ### Checksum in image: ### mysqlbackup: ERROR: Problem verifying checksum of initial header of backup image. Image Path = /meb/backups/image.mbi mysqlbackup: ERROR: Backup image validation failed.
.ibd
这是包含损坏文件 的图像的示例输出 :mysqlbackup: ERROR: datadir/db2/bigtab1.ibd has corrupt page number : 64 page number from page header : 64 mysqlbackup: ERROR: datadir/db2/bigtab1.ibd is corrupt and has : 10 corrupt pages mysqlbackup: ERROR: datadir/db2/t1.ibd has corrupt page number : 4 page number from page header : 0 ....... mysqlbackup: ERROR: datadir/db2/t1.ibd is corrupt and has : 5 corrupt pages mysqlbackup: ERROR: datadir/ibdata1 has corrupt page number : 63 page number from page header : 63 mysqlbackup: ERROR: datadir/ibdata1 has corrupt page number : 7 page number from page header : 7 .......... mysqlbackup: ERROR: datadir/ibdata1 is corrupt and has : 10 corrupt pages mysqlbackup failed with errors!
这是成功验证压缩备份目录的示例输出
mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm5.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm6.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm7.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm8.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabnorm9.ibz Validated... mysqlbackup: INFO: /backups/backup-dir/datadir/tpch/tabrowformat.ibz Validated... 140219 11:22:45 mysqlbackup: INFO: Validate backup directory operation completed successfully.