MySQL 企业备份用户指南(版本 8.0.31) / 第二部分使用 MySQL 企业备份 / 第 4 章备份数据库服务器 / 4.2 典型的备份/验证/恢复周期 /
4.2.2 备份整个MySQL实例
在下面的示例中,我们使用命令将整个 MySQL 实例备份到单个文件,该
backup-to-image
命令出现在示例命令的末尾。--user
我们使用和--host
选项指定数据库的一些连接信息
(并使用该--password
选项告诉 MySQL 服务器提示输入用户密码)。单个文件备份的位置和文件名使用该
--backup-image
选项指定,用于存储临时文件的空文件夹的位置由该--backup-dir
选项提供。
输出回显备份操作使用的所有参数,包括使用数据库连接自动检索的几个参数。此备份作业的唯一 ID 记录在 mysqlbackup在 MySQL 实例中创建的特殊表中,允许您监视长时间运行的备份并查看以前备份的信息。最后的输出部分重复了备份数据的位置,并提供了 LSN值,您在下次对 刚刚创建 的完整备份执行 增量备份时可能会用到这些值。
$ ./mysqlbackup --user=root --password --host=127.0.0.1 --backup-image=/home/admin/backups/my.mbi \
--backup-dir=/home/admin/backup-tmp backup-to-image
MySQL Enterprise Backup version 3.12.5 Linux-2.6.18-274.el5-i686 [2014/11/12]
Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved.
mysqlbackup: INFO: Starting with following command line ...
./mysqlbackup --user=root --password --host=127.0.0.1
--backup-image=/home/admin/backups/my.mbi
--backup-dir=/home/admin/backup-tmp backup-to-image
mysqlbackup: INFO:
Enter password:
mysqlbackup: INFO: MySQL server version is '5.6.17-log'.
mysqlbackup: INFO: Got some server configuration information from running server.
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'backup-to-image' run mysqlbackup
prints "mysqlbackup completed OK!".
141204 12:54:55 mysqlbackup: INFO: MEB logfile created at /home/admin/backup-tmp/meta/MEB_2014-12-04.12-54-55_image_backup.log
--------------------------------------------------------------------
Server Repository Options:
--------------------------------------------------------------------
datadir = /var/lib/mysql/
innodb_data_home_dir =
innodb_data_file_path = ibdata1:12M:autoextend
innodb_log_group_home_dir = /var/lib/mysql/
innodb_log_files_in_group = 2
innodb_log_file_size = 50331648
innodb_page_size = 16384
innodb_checksum_algorithm = innodb
innodb_undo_directory = /var/lib/mysql/
innodb_undo_tablespaces = 0
innodb_undo_logs = 128
--------------------------------------------------------------------
Backup Config Options:
--------------------------------------------------------------------
datadir = /home/admin/backup-tmp/datadir
innodb_data_home_dir = /home/admin/backup-tmp/datadir
innodb_data_file_path = ibdata1:12M:autoextend
innodb_log_group_home_dir = /home/admin/backup-tmp/datadir
innodb_log_files_in_group = 2
innodb_log_file_size = 50331648
innodb_page_size = 16384
innodb_checksum_algorithm = innodb
innodb_undo_directory = /home/admin/backup-tmp/datadir
innodb_undo_tablespaces = 0
innodb_undo_logs = 128
Backup Image Path = /home/admin/backups/my.mbi
mysqlbackup: INFO: Unique generated backup id for this is 14177156956623554
mysqlbackup: INFO: Creating 14 buffers each of size 16777216.
141204 12:54:58 mysqlbackup: INFO: Full Image Backup operation starts with following threads
1 read-threads 6 process-threads 1 write-threads
141204 12:54:58 mysqlbackup: INFO: System tablespace file format is Antelope.
141204 12:54:58 mysqlbackup: INFO: Starting to copy all innodb files...
mysqlbackup: INFO: Copying meta file /home/admin/backup-tmp/backup-my.cnf.
mysqlbackup: INFO: Copying meta file /home/admin/backup-tmp/meta/backup_create.xml.
141204 12:54:58 mysqlbackup: INFO: Found checkpoint at lsn 1631766.
141204 12:54:58 mysqlbackup: INFO: Starting log scan from lsn 1631744.
141204 12:54:58 mysqlbackup: INFO: Copying log...
141204 12:54:58 mysqlbackup: INFO: Log copied, lsn 1631766.
141204 12:54:58 mysqlbackup: INFO: Copying /var/lib/mysql/ibdata1 (Antelope file format).
141204 12:54:59 mysqlbackup: INFO: Copying /var/lib/mysql/mysql/innodb_index_stats.ibd (Antelope file format).
141204 12:54:59 mysqlbackup: INFO: Copying /var/lib/mysql/mysql/innodb_table_stats.ibd (Antelope file format).
141204 12:54:59 mysqlbackup: INFO: Copying /var/lib/mysql/mysql/slave_master_info.ibd (Antelope file format).
141204 12:55:00 mysqlbackup: INFO: Copying /var/lib/mysql/mysql/slave_relay_log_info.ibd (Antelope file format).
141204 12:55:00 mysqlbackup: INFO: Copying /var/lib/mysql/mysql/slave_worker_info.ibd (Antelope file format).
141204 12:55:00 mysqlbackup: INFO: Copying /var/lib/mysql/test2/tb1.ibd (Antelope file format).
141204 12:55:00 mysqlbackup: INFO: Completing the copy of innodb files.
141204 12:55:00 mysqlbackup: INFO: Starting to copy Binlog files...
141204 12:55:01 mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server.
141204 12:55:01 mysqlbackup: INFO: Starting to lock all the tables...
141204 12:55:02 mysqlbackup: INFO: All tables are locked and flushed to disk
141204 12:55:02 mysqlbackup: INFO: Completed the copy of binlog files...
141204 12:55:02 mysqlbackup: INFO: Opening backup source directory '/var/lib/mysql/'
141204 12:55:02 mysqlbackup: INFO: Starting to backup all non-innodb files in
subdirectories of '/var/lib/mysql/'
141204 12:55:02 mysqlbackup: INFO: Adding database directory: datadir/mysql
141204 12:55:02 mysqlbackup: INFO: Adding database directory: datadir/performance_schema
141204 12:55:02 mysqlbackup: INFO: Completing the copy of all non-innodb files.
141204 12:55:02 mysqlbackup: INFO: Adding database directory: datadir/test
141204 12:55:02 mysqlbackup: INFO: Adding database directory: datadir/test2
141204 12:55:04 mysqlbackup: INFO: A copied database page was modified at 1631766.
(This is the highest lsn found on page)
Scanned log up to lsn 1631766.
Was able to parse the log up to lsn 1631766.
Maximum page number for a log record 0
141204 12:55:04 mysqlbackup: INFO: All tables unlocked
141204 12:55:04 mysqlbackup: INFO: All MySQL tables were locked for 2.057 seconds.
141204 12:55:04 mysqlbackup: INFO: Reading all global variables from the server.
141204 12:55:04 mysqlbackup: INFO: Completed reading of all global variables from the server.
141204 12:55:04 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /home/admin/backup-tmp
mysqlbackup: INFO: Copying meta file /home/admin/backup-tmp/meta/backup_variables.txt.
mysqlbackup: INFO: Copying meta file /home/admin/backup-tmp/datadir/ibbackup_logfile.
mysqlbackup: INFO: Copying meta file /home/admin/backup-tmp/server-all.cnf.
mysqlbackup: INFO: Copying meta file /home/admin/backup-tmp/server-my.cnf.
mysqlbackup: INFO: Copying meta file /home/admin/backup-tmp/meta/backup_content.xml.
mysqlbackup: INFO: Copying meta file /home/admin/backup-tmp/meta/image_files.xml.
141204 12:55:08 mysqlbackup: INFO: Full Image Backup operation completed successfully.
141204 12:55:08 mysqlbackup: INFO: Backup image created successfully.
mysqlbackup: INFO: Image Path = /home/admin/backups/my.mbi
141204 12:55:08 mysqlbackup: INFO: MySQL binlog position: filename mysqld-bin.000004, position 120
-------------------------------------------------------------
Parameters Summary
-------------------------------------------------------------
Start LSN : 1631744
End LSN : 1631766
-------------------------------------------------------------
mysqlbackup completed OK!