MySQL 企业备份用户指南(版本 8.0.31) / 第二部分使用 MySQL 企业备份 / 第 4 章备份数据库服务器 / 4.2 典型的备份/验证/恢复周期 /
4.2.2 备份整个MySQL实例
在下面的示例中,我们使用命令将整个 MySQL 实例备份到单个文件,该
backup-to-image
命令出现在示例命令的末尾。--user
我们使用和--host
选项指定数据库的一些连接信息
(并使用该--password
选项告诉
mysqlbackup提示输入用户密码)。单个文件备份的位置和文件名使用该--backup-image
选项指定,用于存储临时文件的空文件夹的位置由该
--backup-dir
选项提供。
输出回显备份操作使用的所有参数,包括使用数据库连接自动检索的几个参数。此备份作业的唯一 ID 记录在 mysqlbackup在 MySQL 实例中创建的特殊表中,允许您监视长时间运行的备份并查看以前备份的信息。最后的输出部分重复了备份数据的位置,并提供了 LSN值,您在下次对 刚刚创建 的完整备份执行 增量备份时可能会用到这些值。
$ ./bin/mysqlbackup --user=mysqlbackup --password --host=127.0.0.1 --backup-dir=/home/meb/mysql/backup-temp \
--backup-image=/home/meb/mysql/backups/testback3.mbi --with-timestamp backup-to-image
MySQL Enterprise Backup Ver 8.0.31-commercial for Linux on x86_64 (MySQL Enterprise - Commercial)
Copyright (c) 2003, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Starting with following command line ...
./bin/mysqlbackup
--user=mysqlbackup
--password
--host=127.0.0.1
--backup-dir=/home/meb/mysql/backup-temp
--backup-image=/home/meb/mysql/backups/testback3.mbi
--with-timestamp
backup-to-image
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'backup-to-image' run mysqlbackup
prints "mysqlbackup completed OK!".
Enter password:
220913 14:49:04 MAIN INFO: Establishing connection to server.
220913 14:49:04 MAIN INFO: No SSL options specified.
220913 14:49:04 MAIN INFO: MySQL server version is '8.0.31-commercial'
220913 14:49:04 MAIN INFO: MySQL server compile os version is 'Linux'
220913 14:49:04 MAIN INFO: SSL/TLS version used for connection is TLSv1.3
220913 14:49:04 MAIN INFO: Got some server configuration information from running server.
220913 14:49:04 MAIN INFO: Establishing connection to server for locking.
220913 14:49:04 MAIN INFO: No SSL options specified.
220913 14:49:04 MAIN INFO: Backup directory created: '/home/meb/mysql/backup-temp/2022-09-13_14-49-04'
220913 14:49:04 MAIN INFO: MySQL server version_comment is 'MySQL Enterprise Server - Commercial'
220913 14:49:04 MAIN INFO: Mysqlbackup component not installed.
220913 14:49:04 MAIN INFO: MEB logfile created at /home/meb/mysql/backup-temp/2022-09-13_14-49-04/meta/MEB_2022-09-13.14-49-04_backup-to-image.log
220913 14:49:04 MAIN INFO: The MySQL server has no active keyring.
--------------------------------------------------------------------
Server Repository Options:
--------------------------------------------------------------------
datadir = /home/meb/mysql/mysql-datadir/
innodb_data_home_dir =
innodb_data_file_path = ibdata1:12M:autoextend
innodb_log_group_home_dir = /home/meb/mysql/mysql-datadir/
innodb_undo_directory = /home/meb/mysql/mysql-datadir/
innodb_undo_tablespaces = 2
innodb_buffer_pool_filename = ib_buffer_pool
innodb_page_size = 16384
innodb_checksum_algorithm = crc32
--------------------------------------------------------------------
Backup Config Options:
--------------------------------------------------------------------
datadir = /home/meb/mysql/backup-temp/2022-09-13_14-49-04/datadir
innodb_data_home_dir = /home/meb/mysql/backup-temp/2022-09-13_14-49-04/datadir
innodb_data_file_path = ibdata1:12M:autoextend
innodb_log_group_home_dir = /home/meb/mysql/backup-temp/2022-09-13_14-49-04/datadir
innodb_undo_directory = /home/meb/mysql/backup-temp/2022-09-13_14-49-04/datadir
innodb_undo_tablespaces = 2
innodb_buffer_pool_filename = ib_buffer_pool
innodb_page_size = 16384
innodb_checksum_algorithm = crc32
Backup Image Path = /home/meb/mysql/backups/testback3.mbi
220913 14:49:04 MAIN INFO: Unique generated backup id for this is 16630949446348741
220913 14:49:04 MAIN INFO: Copying the server config file '/home/meb/mysql/mysql-datadir/auto.cnf'
220913 14:49:04 MAIN INFO: Creating 14 buffers each of size 16777216.
220913 14:49:04 MAIN INFO: The server is not configured for redo log archiving. The system variable innodb_redo_log_archive_dirs is not set.
220913 14:49:04 MAIN INFO: Found checkpoint at lsn 19778447.
220913 14:49:04 MAIN INFO: Starting log scan from lsn = 19778048 at offset = 123791 and checkpoint = 19778447 in file /home/meb/mysql/mysql-datadir/#innodb_redo/#ib_redo6.
220913 14:49:04 MAIN INFO: Full Image Backup operation starts with following threads
1 read-threads 6 process-threads 1 write-threads
220913 14:49:04 RDR1 INFO: Copying meta file /home/meb/mysql/backup-temp/2022-09-13_14-49-04/backup-my.cnf.
220913 14:49:04 RDR1 INFO: Copying meta file /home/meb/mysql/backup-temp/2022-09-13_14-49-04/meta/backup_create.xml.
220913 14:49:04 RDR1 INFO: Copying meta file /home/meb/mysql/backup-temp/2022-09-13_14-49-04/datadir/backup-auto.cnf.
220913 14:49:04 RLP1 INFO: Starting to parse redo log at lsn = 19778077, whereas checkpoint_lsn = 19778447 and start_lsn = 19778048.
220913 14:49:04 RDR1 INFO: Starting to copy all innodb files...
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/ibdata1.
220913 14:49:04 RDR1 INFO: Starting to copy all undo files...
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/undo_002.
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/undo_001.
220913 14:49:04 RDR1 INFO: Starting to lock instance for backup...
220913 14:49:04 RDR1 INFO: The server instance is locked for backup.
220913 14:49:04 RDR1 INFO: The server instance is unlocked after 0.004 seconds.
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/sys/sys_config.ibd.
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/Test/test1.ibd.
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/mysql/backup_progress.ibd.
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/mysql/backup_history.ibd.
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/mysql.ibd.
220913 14:49:04 RDR1 INFO: Completing the copy of innodb files.
220913 14:49:04 RDR1 INFO: Requesting a dump of the InnoDB buffer pool
220913 14:49:04 RDR1 INFO: Waiting for the dump of the InnoDB buffer pool to complete
220913 14:49:04 RDR1 INFO: The dump of the InnoDB buffer pool completed
220913 14:49:04 RDR1 INFO: Binary Log Basename: '/home/meb/mysql/mysql-datadir/binlog'
220913 14:49:04 RDR1 INFO: Binary Log Index: '/home/meb/mysql/mysql-datadir/binlog.index'
220913 14:49:04 RDR1 INFO: Relay Channel: 'group_replication_applier'
220913 14:49:04 RDR1 INFO: Relay Log Basename: '/home/meb/mysql/mysql-datadir/meb-XBox3-relay-bin-group_replication_applier'
220913 14:49:04 RDR1 INFO: Relay Channel: 'group_replication_recovery'
220913 14:49:04 RDR1 INFO: Relay Log Basename: '/home/meb/mysql/mysql-datadir/meb-XBox3-relay-bin-group_replication_recovery'
220913 14:49:04 RDR1 INFO: Starting to copy Binlog files.
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/binlog.000001.
220913 14:49:04 RDR1 INFO: Starting to lock instance for backup...
220913 14:49:04 RDR1 INFO: The server instance is locked for backup.
220913 14:49:04 RDR1 INFO: The MySQL server has no active keyring.
220913 14:49:04 RDR1 INFO: Requesting flush of redo log reading after LSN 19781380.
220913 14:49:04 RDR1 INFO: Requesting flush of redo log processing after LSN 19781380.
220913 14:49:04 RDR1 INFO: Completed flush of redo log reading after LSN 19784275.
220913 14:49:04 RDR1 INFO: Completed flush of redo log processing after LSN 19784275.
220913 14:49:04 RDR1 INFO: Starting to read-lock tables...
220913 14:49:04 RDR1 INFO: No tables to read-lock.
220913 14:49:04 RDR1 INFO: Opening backup source directory '/home/meb/mysql/mysql-datadir'
220913 14:49:04 RDR1 INFO: Starting to copy non-innodb files in subdirs of '/home/meb/mysql/mysql-datadir'
220913 14:49:04 WTR1 INFO: Adding database directory: datadir/Test
220913 14:49:04 WTR1 INFO: Adding database directory: datadir/mysql
220913 14:49:04 WTR1 INFO: Adding database directory: datadir/performance_schema
220913 14:49:04 RDR1 INFO: Completing the copy of all non-innodb files.
220913 14:49:04 WTR1 INFO: Adding database directory: datadir/sys
220913 14:49:04 RDR1 INFO: Requesting consistency information...
220913 14:49:04 RDR1 INFO: Locked the consistency point for 353 microseconds.
220913 14:49:04 RDR1 INFO: Consistency point server_uuid '98bbd252-3374-11ed-8e69-0800276c22b0'.
220913 14:49:04 RDR1 INFO: Consistency point gtid_executed ''.
220913 14:49:04 RDR1 INFO: Consistency point binary_log_file 'binlog.000002'.
220913 14:49:04 RDR1 INFO: Consistency point binary_log_position 157.
220913 14:49:04 RDR1 INFO: Consistency point InnoDB lsn 19785442.
220913 14:49:04 RDR1 INFO: Consistency point InnoDB lsn_checkpoint 19778447.
220913 14:49:04 RDR1 INFO: Requesting completion of redo log copy after LSN 19785442.
220913 14:49:04 RLW1 INFO: A copied database page was modified at 19778447. (This is the highest lsn found on a page)
220913 14:49:04 RLW1 INFO: Scanned log up to lsn 19785442.
220913 14:49:04 RLW1 INFO: Was able to parse the log up to lsn 19785442.
220913 14:49:04 RLR1 INFO: Redo log reader waited 33 times for a total of 165.00 ms for logs to generate.
220913 14:49:04 RLW1 INFO: Copied redo log
log_start_lsn 19778048
start_checkpoint 19778447
start_lsn 19778447
last_checkpoint 19778447
consistency_lsn 19785442
log_end_lsn 19785442
220913 14:49:04 RDR1 INFO: Truncating binary log index '/home/meb/mysql/backup-temp/2022-09-13_14-49-04/datadir/binlog.index' to 32.
220913 14:49:04 RDR1 INFO: Truncating binary log 'binlog.000002' to 157.
220913 14:49:04 RDR1 INFO: Copying /home/meb/mysql/mysql-datadir/binlog.000002.
220913 14:49:04 RDR1 INFO: Completed the copy of binlog files...
220913 14:49:04 RDR1 INFO: The server instance is unlocked after 0.100 seconds.
220913 14:49:04 RDR1 INFO: Reading all global variables from the server.
220913 14:49:04 RDR1 INFO: Completed reading of all 631 global variables from the server.
220913 14:49:04 RDR1 INFO: Writing server defaults files 'server-my.cnf' and 'server-all.cnf' for server '8.0.31-commercial' in '/home/meb/mysql/backup-temp/2022-09-13_14-49-04'.
220913 14:49:04 RDR1 INFO: Copying meta file /home/meb/mysql/backup-temp/2022-09-13_14-49-04/meta/backup_variables.txt.
220913 14:49:04 RDR1 INFO: Copying meta file /home/meb/mysql/backup-temp/2022-09-13_14-49-04/datadir/ibbackup_logfile.
220913 14:49:04 RDR1 INFO: Copying meta file /home/meb/mysql/backup-temp/2022-09-13_14-49-04/server-all.cnf.
220913 14:49:04 RDR1 INFO: Copying meta file /home/meb/mysql/backup-temp/2022-09-13_14-49-04/server-my.cnf.
220913 14:49:04 RDR1 INFO: Copying meta file /home/meb/mysql/backup-temp/2022-09-13_14-49-04/meta/backup_content.xml.
220913 14:49:05 RDR1 INFO: Copying meta file /home/meb/mysql/backup-temp/2022-09-13_14-49-04/meta/image_files.xml.
220913 14:49:05 MAIN INFO: Full Image Backup operation completed successfully.
220913 14:49:05 MAIN INFO: Backup image created successfully.
220913 14:49:05 MAIN INFO: Image Path = /home/meb/mysql/backups/testback3.mbi
220913 14:49:05 MAIN INFO: MySQL binlog position: filename binlog.000002, position 157
-------------------------------------------------------------
Parameters Summary
-------------------------------------------------------------
Start LSN : 19778048
Last Checkpoint LSN : 19778447
End LSN : 19785442
-------------------------------------------------------------
mysqlbackup completed OK!