mysqldump当数据量很大的时候,不建议使用此工具,应当采用的是oracle公司提供了针对企业的备份软件Mysql Enterprise Backup简称mysqlbackup
一、安装
[[email protected] bjia]# unzip p19957495_3110_Linux-x86-64.zip [[email protected] bjia]# tar zxvf meb-3.11.1-linux-glibc2.5-x86-64bit.tar.gz [[email protected] meb-3.11.1-linux-glibc2.5-x86-64bit]# cd meb-3.11.1-linux-glibc2.5-x86-64bit [[email protected] meb-3.11.1-linux-glibc2.5-x86-64bit]# cd bin [[email protected] bin]# cp mysqlbackup /usr/bin/ 至此Mysqlbackup工具已经安装完成
二、全量备份
mysqlbackup --socket=/tmp/mysql3003.sock --backup-dir=/root/ --with-timestamp backup-and-apply-log MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. Starting with following command line ... mysqlbackup --socket=/tmp/mysql3003.sock --backup-dir=/root/ --with-timestamp backup-and-apply-log MySQL server version is ‘5.6.23‘. Got some server configuration information from running server. IMPORTANT: Please check that mysqlbackup run completes successfully. At the end of a successful ‘backup-and-apply-log‘ run mysqlbackup prints "mysqlbackup completed OK!". 150602 12:20:00 mysqlbackup: INFO: MEB logfile created at /root/2015-06-02_12-20-00/meta/MEB_2015-06-02.12-20-00_backup_apply_log.log -------------------------------------------------------------------- Server Repository Options: -------------------------------------------------------------------- datadir = /9tong/mysql/data/3003/ innodb_data_home_dir = innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /9tong/mysql/data/3003/ innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb innodb_undo_directory = /9tong/mysql/data/3003/ innodb_undo_tablespaces = 0 innodb_undo_logs = 128 -------------------------------------------------------------------- Backup Config Options: -------------------------------------------------------------------- datadir = /root/2015-06-02_12-20-00/datadir innodb_data_home_dir = /root/2015-06-02_12-20-00/datadir innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /root/2015-06-02_12-20-00/datadir innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb innodb_undo_directory = /root/2015-06-02_12-20-00/datadir innodb_undo_tablespaces = 0 innodb_undo_logs = 128 mysqlbackup: INFO: Unique generated backup id for this is 14332188007400510 mysqlbackup: INFO: Creating 14 buffers each of size 16777216. 150602 12:20:02 mysqlbackup: INFO: Full Backup operation starts with following threads 1 read-threads 6 process-threads 1 write-threads 150602 12:20:02 mysqlbackup: INFO: System tablespace file format is Antelope. 150602 12:20:02 mysqlbackup: INFO: Starting to copy all innodb files... mysqlbackup: INFO: Could not find binlog index file. binlogs will not be copied for this backup. Point-In-Time-Recovery will not be possible. If this is online backup then server may not have started with --log-bin. You may specify its location with --log-bin-index option. 150602 12:20:03 mysqlbackup: INFO: Found checkpoint at lsn 171444289872. 150602 12:20:03 mysqlbackup: INFO: Starting log scan from lsn 171444289536. 150602 12:20:03 mysqlbackup: INFO: Copying log... 150602 12:20:03 mysqlbackup: INFO: Copying /9tong/mysql/data/3003/ibdata1 (Antelope file format). 150602 12:20:03 mysqlbackup: INFO: Log copied, lsn 171444289872. mysqlbackup: Progress in MB: 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 5200 5400 5600 5800 6000 6200 6400 6600 6800 7000 7200 7400 7600 7800 8000 8200 8400 8600 8800 9000 9200 9400 9600 9800 10000 10200 10400 10600 10800 11000 11200 11400 11600 11800 12000 12200 12400 12600 12800 13000 13200 13400 13600 13800 14000 14200 14400 14600 14800 15000 15200 15400 15600 15800 16000 16200 16400 16600 16800 17000 17200 17400 17600 17800 18000 18200 18400 18600 18800 19000 150602 12:28:24 mysqlbackup: INFO: Completing the copy of innodb files. 150602 12:28:25 mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server. 150602 12:28:25 mysqlbackup: INFO: Starting to lock all the tables... 150602 12:28:25 mysqlbackup: INFO: All tables are locked and flushed to disk 150602 12:28:25 mysqlbackup: INFO: Opening backup source directory ‘/9tong/mysql/data/3003/‘ 150602 12:28:25 mysqlbackup: INFO: Starting to backup all non-innodb files in subdirectories of ‘/9tong/mysql/data/3003/‘ 150602 12:28:25 mysqlbackup: INFO: Copying the database directory ‘9tong_ur‘ 150602 12:28:27 mysqlbackup: INFO: Copying the database directory ‘9tong_user‘ 150602 12:28:28 mysqlbackup: INFO: Copying the database directory ‘aclocal‘ 150602 12:28:28 mysqlbackup: INFO: Copying the database directory ‘mysql‘ 150602 12:28:28 mysqlbackup: INFO: Copying the database directory ‘performance_schema‘ 150602 12:28:28 mysqlbackup: INFO: Copying the database directory ‘ps_helper‘ 150602 12:28:28 mysqlbackup: INFO: Copying the database directory ‘sys‘ 150602 12:28:29 mysqlbackup: INFO: Copying the database directory ‘test‘ 150602 12:28:29 mysqlbackup: INFO: Completing the copy of all non-innodb files. 150602 12:28:29 mysqlbackup: INFO: A copied database page was modified at 171444289872. (This is the highest lsn found on page) Scanned log up to lsn 171444289872. Was able to parse the log up to lsn 171444289872. Maximum page number for a log record 0 150602 12:28:29 mysqlbackup: INFO: All tables unlocked 150602 12:28:29 mysqlbackup: INFO: All MySQL tables were locked for 4.072 seconds. 150602 12:28:29 mysqlbackup: INFO: Reading all global variables from the server. 150602 12:28:29 mysqlbackup: INFO: Completed reading of all global variables from the server. 150602 12:28:29 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /root/2015-06-02_12-20-00 150602 12:28:30 mysqlbackup: INFO: Full Backup operation completed successfully. 150602 12:28:30 mysqlbackup: INFO: Backup created in directory ‘/root/2015-06-02_12-20-00‘ ------------------------------------------------------------- Parameters Summary ------------------------------------------------------------- Start LSN : 171444289536 End LSN : 171444289872 ------------------------------------------------------------- mysqlbackup: INFO: Creating 14 buffers each of size 65536. 150602 12:28:30 mysqlbackup: INFO: Apply-log operation starts with following threads 1 read-threads 1 process-threads mysqlbackup: INFO: Using up to 100 MB of memory. 150602 12:28:30 mysqlbackup: INFO: ibbackup_logfile‘s creation parameters: start lsn 171444289536, end lsn 171444289872, start checkpoint 171444289872. mysqlbackup: INFO: InnoDB: Starting an apply batch of log records to the database... mysqlbackup: INFO: InnoDB: Setting log file size to 4294967296 mysqlbackup: INFO: InnoDB: Setting log file size to 4294967296 150602 12:30:32 mysqlbackup: INFO: We were able to parse ibbackup_logfile up to lsn 171444289872. mysqlbackup: INFO: Last MySQL binlog file position 0 791363474, file name mysql-bin.000023 150602 12:30:34 mysqlbackup: INFO: The first data file is ‘/root/2015-06-02_12-20-00/datadir/ibdata1‘ and the new created log files are at ‘/root/2015-06-02_12-20-00/datadir‘ 150602 12:30:34 mysqlbackup: INFO: Apply-log operation completed successfully. 150602 12:30:34 mysqlbackup: INFO: Full backup prepared for recovery successfully. mysqlbackup completed OK! [[email protected] ~]# du -sh 2015-06-02_12-20-00/ 27G 2015-06-02_12-20-00/ 10分钟的时间,全备出时间10分钟。速度效率高啊!!! 参数: --with-timestamp:为每一个备份目录增加时间戳,非常有用的一个参数 --backdir:备份的路径 --backup-and-apply-log :全备的事物日志文件
三、全量恢复
[email protected] 3003]# mysqlbackup --datadir=/9tong/mysql/data/3003 --socket=/tmp/mysql3003.sock --backup-dir=/root/2015-06-02_12-20-00/ copy-back MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... mysqlbackup --datadir=/9tong/mysql/data/3003 --socket=/tmp/mysql3003.sock --backup-dir=/root/2015-06-02_12-20-00/ copy-back mysqlbackup: INFO: IMPORTANT: Please check that mysqlbackup run completes successfully. At the end of a successful ‘copy-back‘ run mysqlbackup prints "mysqlbackup completed OK!". 150602 15:45:05 mysqlbackup: INFO: MEB logfile created at /root/2015-06-02_12-20-00/meta/MEB_2015-06-02.15-45-05_copy_back.log mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_data_file_path parameter might have a different default. In that case you need to add ‘innodb_data_file_path=ibdata1:12M:autoextend‘ to the target server configuration. mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_log_files_in_group parameter might have a different default. In that case you need to add ‘innodb_log_files_in_group=2‘ to the target server configuration. mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_log_file_size parameter might have a different default. In that case you need to add ‘innodb_log_file_size=4294967296‘ to the target server configuration. -------------------------------------------------------------------- Server Repository Options: -------------------------------------------------------------------- datadir = /9tong/mysql/data/3003 innodb_data_home_dir = /9tong/mysql/data/3003 innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /9tong/mysql/data/3003 innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = Null innodb_checksum_algorithm = innodb -------------------------------------------------------------------- Backup Config Options: -------------------------------------------------------------------- datadir = /root/2015-06-02_12-20-00/datadir innodb_data_home_dir = /root/2015-06-02_12-20-00/datadir innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /root/2015-06-02_12-20-00/datadir innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb mysqlbackup: INFO: Creating 14 buffers each of size 16777216. 150602 15:45:06 mysqlbackup: INFO: Copy-back operation starts with following threads 1 read-threads 1 write-threads mysqlbackup: INFO: Could not find binlog index file. binlogs will not be copied for this backup. Point-In-Time-Recovery will not be possible. If this is online backup then server may not have started with --log-bin. You may specify its location with --log-bin-index option. 150602 15:45:06 mysqlbackup: INFO: Copying /root/2015-06-02_12-20-00/datadir/ibdata1. mysqlbackup: Progress in MB: 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 5200 5400 5600 5800 6000 6200 6400 6600 6800 7000 7200 7400 7600 7800 8000 8200 8400 8600 8800 9000 9200 9400 9600 9800 10000 10200 10400 10600 10800 11000 11200 11400 11600 11800 12000 12200 12400 12600 12800 13000 13200 13400 13600 13800 14000 14200 14400 14600 14800 15000 15200 15400 15600 15800 16000 16200 16400 16600 16800 17000 17200 17400 17600 17800 18000 18200 18400 18600 18800 19000 19200 150602 15:53:27 mysqlbackup: INFO: Copying the database directory ‘9tong_ur‘ 150602 15:53:29 mysqlbackup: INFO: Copying the database directory ‘9tong_user‘ 150602 15:53:29 mysqlbackup: INFO: Copying the database directory ‘aclocal‘ 150602 15:53:29 mysqlbackup: INFO: Copying the database directory ‘mysql‘ 150602 15:53:29 mysqlbackup: INFO: Copying the database directory ‘performance_schema‘ 150602 15:53:29 mysqlbackup: INFO: Copying the database directory ‘ps_helper‘ 150602 15:53:29 mysqlbackup: INFO: Copying the database directory ‘sys‘ 150602 15:53:29 mysqlbackup: INFO: Copying the database directory ‘test‘ 150602 15:53:29 mysqlbackup: INFO: Copying the database directory ‘zxl‘ 150602 15:53:29 mysqlbackup: INFO: Completing the copy of all non-innodb files. 150602 15:53:29 mysqlbackup: INFO: Copying the log file ‘ib_logfile0‘ mysqlbackup: Progress in MB: 19400 19600 19800 20000 20200 20400 20600 20800 21000 21200 21400 21600 21800 22000 22200 22400 22600 22800 23000 23200 150602 15:55:23 mysqlbackup: INFO: Copying the log file ‘ib_logfile1‘ mysqlbackup: Progress in MB: 23400 23600 23800 24000 24200 24400 24600 24800 25000 25200 25400 25600 25800 26000 26200 26400 26600 26800 27000 27200 27400 150602 15:57:21 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /9tong/mysql/data/3003 150602 15:57:21 mysqlbackup: INFO: Copy-back operation completed successfully. 150602 15:57:21 mysqlbackup: INFO: Finished copying backup files to ‘/9tong/mysql/data/3003‘ mysqlbackup completed OK! with 3 warnings
备份完毕,务必要对data目录授权,否则没有权限操作读写数据库。
[[email protected] 3003]# chown -R mysql.mysql /9tong/mysql/data/3003/*
重启一下数据库,否则无法读取表的结构,这个也是非常重要的 [[email protected] 3003]#mysqladmin -u root -S /tmp/mysql3003 shutdown [[email protected] 3003]#mysqld_multi start 1-2 Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | 9tong_ur | | 9tong_user | | aclocal | | mysql | | performance_schema | | ps_helper | | sys | | test | | zxl | +--------------------+ 10 rows in set (0.00 sec) mysql> desc user_works; +-------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | uid | int(11) | NO | MUL | 0 | | | companyName | varchar(100) | NO | | | | | title | varchar(30) | NO | | | | | location | varchar(30) | NO | | | | | startYear | decimal(4,0) | NO | | 0 | | | startMonth | decimal(2,0) | NO | | 0 | | | endYear | decimal(4,0) | NO | | 0 | | | endMonth | decimal(2,0) | NO | | 0 | | | description | varchar(1000) | NO | | | | | createTime | decimal(16,0) | NO | | 0 | | | modifyTime | decimal(16,0) | NO | | 0 | | | industry | varchar(16) | NO | | | | +-------------+---------------+------+-----+---------+----------------+ 13 rows in set (0.00 sec)
至此,完全导入23G的数据量只要12分钟。
四、第一次增量备份
为了验证增量备份的可靠性,首先导入一张表 mysql> create table user_account2016 as select * from user_account; [[email protected] ~]# /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --incremental --incremental-base=dir:/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root backup MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --incremental --incremental-base=dir:/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root backup mysqlbackup: INFO: mysqlbackup: INFO: MySQL server version is ‘5.6.23‘. mysqlbackup: INFO: Got some server configuration information from running server. mysqlbackup: ERROR: Backup directory already exists and is not empty. Please remove backup directory and retry. mysqlbackup failed with errors! [[email protected] ~]# /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --incremental --incremental-base=dir:/root/ --incremental-backup-dir=/root/2015-06-02_1 backup 2015-06-02_11-00-55/ 2015-06-02_12-20-00/ [[email protected] ~]# /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --incremental --incremental-base=dir:/root/ --incremental-backup-dir=/root/2015-06-02_11-00-55/ backup MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --incremental --incremental-base=dir:/root/ --incremental-backup-dir=/root/2015-06-02_11-00-55/ backup mysqlbackup: INFO: mysqlbackup: INFO: MySQL server version is ‘5.6.23‘. mysqlbackup: INFO: Got some server configuration information from running server. mysqlbackup: ERROR: Backup directory already exists and is not empty. Please remove backup directory and retry. mysqlbackup failed with errors! [[email protected] ~]# /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --incremental --incremental-base=dir:/root/2015-06-02_1 --incremental-backup-dir=/root/2015-06-02_11-00-55/ backup 2015-06-02_11-00-55/ 2015-06-02_12-20-00/ [[email protected] ~]# /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --incremental --incremental-base=dir:/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root/ backup MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --incremental --incremental-base=dir:/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root/ backup mysqlbackup: INFO: mysqlbackup: INFO: MySQL server version is ‘5.6.23‘. mysqlbackup: INFO: Got some server configuration information from running server. mysqlbackup: ERROR: Backup directory already exists and is not empty. Please remove backup directory and retry. mysqlbackup failed with errors! [[email protected] ~]# /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --with-timestamp --incremental --incremental-base=dir:/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root/ backup MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... /usr/local/bin/mysqlbackup --socket=/tmp/mysql3003.sock --with-timestamp --incremental --incremental-base=dir:/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root/ backup mysqlbackup: INFO: mysqlbackup: INFO: MySQL server version is ‘5.6.23‘. 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‘ run mysqlbackup prints "mysqlbackup completed OK!". 150602 13:17:52 mysqlbackup: INFO: MEB logfile created at /root/2015-06-02_13-17-52/meta/MEB_2015-06-02.13-17-52_inc_backup.log 150602 13:17:52 mysqlbackup: INFO: Using start_lsn=171444289872, calculated from backup_variables.txt file of incremental-base backup. -------------------------------------------------------------------- Server Repository Options: -------------------------------------------------------------------- datadir = /9tong/mysql/data/3003/ innodb_data_home_dir = innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /9tong/mysql/data/3003/ innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb innodb_undo_directory = /9tong/mysql/data/3003/ innodb_undo_tablespaces = 0 innodb_undo_logs = 128 -------------------------------------------------------------------- Backup Config Options: -------------------------------------------------------------------- datadir = /root/2015-06-02_13-17-52/datadir innodb_data_home_dir = /root/2015-06-02_13-17-52/datadir innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /root/2015-06-02_13-17-52/datadir innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb innodb_undo_directory = /root/2015-06-02_13-17-52/datadir innodb_undo_tablespaces = 0 innodb_undo_logs = 128 mysqlbackup: INFO: Unique generated backup id for this is 14332222728145270 mysqlbackup: INFO: Creating 14 buffers each of size 16908288. 150602 13:17:55 mysqlbackup: INFO: Incremental Backup operation starts with following threads 1 read-threads 6 process-threads 1 write-threads 150602 13:17:55 mysqlbackup: INFO: System tablespace file format is Antelope. 150602 13:17:55 mysqlbackup: INFO: Starting to copy all innodb files... mysqlbackup: INFO: Could not find binlog index file. binlogs will not be copied for this backup. Point-In-Time-Recovery will not be possible. If this is online backup then server may not have started with --log-bin. You may specify its location with --log-bin-index option. 150602 13:17:55 mysqlbackup: INFO: Found checkpoint at lsn 171829647523. 150602 13:17:55 mysqlbackup: INFO: Starting log scan from lsn 171829647360. 150602 13:17:55 mysqlbackup: INFO: Copying log... 150602 13:17:55 mysqlbackup: INFO: Copying /9tong/mysql/data/3003/ibdata1 (Antelope file format). 150602 13:17:55 mysqlbackup: INFO: Log copied, lsn 171829647523. mysqlbackup: Progress in MB: 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 5200 5400 5600 5800 6000 6200 6400 6600 6800 7000 7200 7400 7600 7800 8000 8200 8400 8600 8800 9000 9200 9400 9600 9800 10000 10200 10400 10600 10800 11000 11200 11400 11600 11800 12000 12200 12400 12600 12800 13000 13200 13400 13600 13800 14000 14200 14400 14600 14800 15000 15200 15400 15600 15800 16000 16200 16400 16600 16800 17000 17200 17400 17600 17800 18000 18200 18400 18600 18800 19000 19200 150602 13:21:42 mysqlbackup: INFO: Completing the copy of innodb files. 150602 13:21:43 mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server. 150602 13:21:43 mysqlbackup: INFO: Starting to lock all the tables... 150602 13:21:43 mysqlbackup: INFO: All tables are locked and flushed to disk 150602 13:21:43 mysqlbackup: INFO: Opening backup source directory ‘/9tong/mysql/data/3003/‘ 150602 13:21:43 mysqlbackup: INFO: Starting to backup all non-innodb files in subdirectories of ‘/9tong/mysql/data/3003/‘ 150602 13:21:43 mysqlbackup: INFO: Copying the database directory ‘9tong_ur‘ 150602 13:21:45 mysqlbackup: INFO: Copying the database directory ‘9tong_user‘ 150602 13:21:46 mysqlbackup: INFO: Copying the database directory ‘aclocal‘ 150602 13:21:46 mysqlbackup: INFO: Copying the database directory ‘mysql‘ 150602 13:21:46 mysqlbackup: INFO: Copying the database directory ‘performance_schema‘ 150602 13:21:46 mysqlbackup: INFO: Copying the database directory ‘ps_helper‘ 150602 13:21:47 mysqlbackup: INFO: Copying the database directory ‘sys‘ 150602 13:21:48 mysqlbackup: INFO: Copying the database directory ‘test‘ 150602 13:21:48 mysqlbackup: INFO: Copying the database directory ‘zxl‘ 150602 13:21:48 mysqlbackup: INFO: Completing the copy of all non-innodb files. 150602 13:21:49 mysqlbackup: INFO: A copied database page was modified at 171829647523. (This is the highest lsn found on page) Scanned log up to lsn 171829647523. Was able to parse the log up to lsn 171829647523. Maximum page number for a log record 0 150602 13:21:49 mysqlbackup: INFO: All tables unlocked 150602 13:21:49 mysqlbackup: INFO: All MySQL tables were locked for 5.470 seconds. 150602 13:21:49 mysqlbackup: INFO: Reading all global variables from the server. 150602 13:21:49 mysqlbackup: INFO: Completed reading of all global variables from the server. 150602 13:21:49 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /root/2015-06-02_13-17-52 150602 13:21:49 mysqlbackup: INFO: Incremental Backup operation completed successfully. 150602 13:21:49 mysqlbackup: INFO: Backup created in directory ‘/root/2015-06-02_13-17-52‘ 150602 13:21:49 mysqlbackup: INFO: Backup contains changes from lsn 171444289873 to lsn 171829647523 ------------------------------------------------------------- Parameters Summary ------------------------------------------------------------- Start LSN : 171444289873 End LSN : 171829647523 ------------------------------------------------------------- [[email protected] ~]# du -sh 2015-06-02_13-17-52/ 316M 2015-06-02_13-17-52/ 增量备份还是比较快的,4分钟完成了 参数: --incremental:代表为增量备份 --incremental-backup-dir:增量备份存放到哪个路径下 --incremental-base: 增量备份的基础备份或增量备份的文件 重要:增量备份的前提必须要有一份完整的全备数据。如果是从一台机器上已经备过来的数据,不能直接用增量备份的,还需要先在导入数据的这台机器上,做一份完全备份,在操作增量备份。因为导入数据的时候会读取数据库存储的LSN,LSN不一致会出现如下错误: mysqlbackup --defaults-file=/etc/my.cnf --socket=/tmp/mysql3001.sock --with-timestamp --incremental --incremental-backup-dir=/root --incremental-base=dir:/usr/loacal/2015-04-07_12-28-31 backup mysqlbackup: ERROR: Log scan was only able to reach to 1630720, but a copied database page was modified at 171444286878. mysqlbackup: INFO: LSN 171444286878 found in the file /9tong/mysql/data/3003/ibdata1 150602 12:05:36 mysqlbackup: INFO: All tables unlocked 150602 12:05:36 mysqlbackup: INFO: All MySQL tables were locked for 8.602 seconds. 150602 12:05:36 mysqlbackup: INFO: Reading all global variables from the server. 150602 12:05:36 mysqlbackup: INFO: Completed reading of all global variables from the server. 150602 12:05:36 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /145mysql/2015-06-02_11-56-53 mysqlbackup failed with errors!
五、第一次增量还原
为了验证增量还原的可靠性删除之前创建的表 drop table user_account2016; 1. 全备检测匹配释放事务日志 mysqlbackup --defaults-file=/etc/my.cnf --backup-dir=/root/015-06-02_12-20-00/ apply-log 2.检测匹配释放第一次的增量备份 mysqlbackup --backup-dir=/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root/2015-06-02_13-17-52/ apply-incremental-backup 3、进行物理文件复制 [[email protected] meta]# mysqlbackup --defaults-file=/etc/my.cnf --datadir=/9tong/mysql/data/3003/ --backup-dir=/root/2015-06-02_12-20-00/ copy-back MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... mysqlbackup --defaults-file=/etc/my.cnf --datadir=/9tong/mysql/data/3003/ --backup-dir=/root/2015-06-02_12-20-00/ copy-back mysqlbackup: INFO: IMPORTANT: Please check that mysqlbackup run completes successfully. At the end of a successful ‘copy-back‘ run mysqlbackup prints "mysqlbackup completed OK!". 150602 13:40:13 mysqlbackup: INFO: MEB logfile created at /root/2015-06-02_12-20-00/meta/MEB_2015-06-02.13-40-13_copy_back.log mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_data_file_path parameter might have a different default. In that case you need to add ‘innodb_data_file_path=ibdata1:12M:autoextend‘ to the target server configuration. mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_log_files_in_group parameter might have a different default. In that case you need to add ‘innodb_log_files_in_group=2‘ to the target server configuration. mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_log_file_size parameter might have a different default. In that case you need to add ‘innodb_log_file_size=4294967296‘ to the target server configuration. -------------------------------------------------------------------- Server Repository Options: -------------------------------------------------------------------- datadir = /9tong/mysql/data/3003/ innodb_data_home_dir = /9tong/mysql/data/3003/ innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /9tong/mysql/data/3003/ innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = Null innodb_checksum_algorithm = innodb -------------------------------------------------------------------- Backup Config Options: -------------------------------------------------------------------- datadir = /root/2015-06-02_12-20-00/datadir innodb_data_home_dir = /root/2015-06-02_12-20-00/datadir innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /root/2015-06-02_12-20-00/datadir innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb mysqlbackup: INFO: Creating 14 buffers each of size 16777216. 150602 13:40:13 mysqlbackup: INFO: Copy-back operation starts with following threads 1 read-threads 1 write-threads mysqlbackup: INFO: Could not find binlog index file. binlogs will not be copied for this backup. Point-In-Time-Recovery will not be possible. If this is online backup then server may not have started with --log-bin. You may specify its location with --log-bin-index option. 150602 13:40:13 mysqlbackup: INFO: Copying /root/2015-06-02_12-20-00/datadir/ibdata1 (to ‘/9tong/mysql/data/3003‘). mysqlbackup: Progress in MB: 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 5200 5400 5600 5800 6000 6200 6400 6600 6800 7000 7200 7400 7600 7800 8000 8200 8400 8600 8800 9000 9200 94009600 9800 10000 10200 10400 10600 10800 11000 11200 11400 11600 11800 12000 12200 12400 12600 12800 13000 13200 13400 13600 13800 14000 14200 14400 14600 14800 15000 15200 15400 15600 15800 16000 16200 16400 16600 16800 17000 17200 17400 17600 17800 18000 18200 18400 18600 18800 19000 19200 150602 13:48:35 mysqlbackup: INFO: Copying the database directory ‘9tong_ur‘ 150602 13:48:39 mysqlbackup: INFO: Copying the database directory ‘9tong_user‘ 150602 13:48:39 mysqlbackup: INFO: Copying the database directory ‘aclocal‘ 150602 13:48:39 mysqlbackup: INFO: Copying the database directory ‘mysql‘ 150602 13:48:40 mysqlbackup: INFO: Copying the database directory ‘performance_schema‘ 150602 13:48:40 mysqlbackup: INFO: Copying the database directory ‘ps_helper‘ 150602 13:48:41 mysqlbackup: INFO: Copying the database directory ‘sys‘ 150602 13:48:42 mysqlbackup: INFO: Copying the database directory ‘test‘ 150602 13:48:42 mysqlbackup: INFO: Copying the database directory ‘zxl‘ 150602 13:48:42 mysqlbackup: INFO: Completing the copy of all non-innodb files. 150602 13:48:42 mysqlbackup: INFO: Copying the log file ‘ib_logfile0‘ mysqlbackup: Progress in MB: 19400 19600 19800 20000 20200 20400 20600 20800 21000 21200 21400 21600 21800 22000 22200 22400 22600 22800 23000 23200 150602 13:50:38 mysqlbackup: INFO: Copying the log file ‘ib_logfile1‘ mysqlbackup: Progress in MB: 23400 23600 23800 24000 24200 24400 24600 24800 25000 25200 25400 25600 25800 26000 26200 26400 26600 26800 27000 27200 27400 150602 13:51:45 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /9tong/mysql/data/3003/ 150602 13:51:45 mysqlbackup: INFO: Copy-back operation completed successfully. 150602 13:51:45 mysqlbackup: INFO: Finished copying backup files to ‘/9tong/mysql/data/3003/‘ mysqlbackup completed OK! with 3 warnings
4、验证增量备份是否正常
mysql> desc user_account2016 ; +--------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+---------------+------+-----+---------+-------+ | id | int(11) | NO | | 0 | | | uid | int(11) | NO | | 0 | | | account | varchar(50) | NO | | | | | pswd | varchar(45) | NO | | | | | realName | varchar(50) | NO | | | | | verifyCode | decimal(10,0) | NO | | 0 | | | verifyTimes | decimal(1,0) | NO | | 0 | | | registerTime | decimal(16,0) | NO | | 0 | | | activeTime | decimal(16,0) | NO | | 0 | | | lastActive | decimal(16,0) | NO | | 0 | | +--------------+---------------+------+-----+---------+-------+ 10 rows in set (0.00 sec) 正常显示,增量备份成功完成。
注:1、首先检查匹配释放全备事物日志文件(当然如果备份中使用了backup-and-apply-log在备份的时候已经检测匹配了,就不需要这一步了。由于做全量备份的时候已经匹配了,故第一步操作可以省去)
2、第一次增量备份的文件释放到全备文件里面(首先会进入事物日志,然后是表空间),所以--backup-dir指向全备目录(基于LSN点向后增量)
5、第二次增量备份
1、做之前先操作以下文件 mysql> drop table user_active_60 ; Query OK, 0 rows affected (0.12 sec) mysql> drop table user_active_15; Query OK, 0 rows affected (0.04 sec) mysql> drop table user_active_30; Query OK, 0 rows affected (0.07 sec) 2、第二次备份操作 [[email protected] meta]# mysqlbackup --backup-dir=/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root/2015-06-02_13-17-52/ apply-incremental-backup MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... mysqlbackup --backup-dir=/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root/2015-06-02_13-17-52/ apply-incremental-backup mysqlbackup: INFO: IMPORTANT: Please check that mysqlbackup run completes successfully. At the end of a successful ‘apply-incremental-backup‘ run mysqlbackup prints "mysqlbackup completed OK!". 150602 13:32:04 mysqlbackup: INFO: MEB logfile created at /root/2015-06-02_12-20-00/meta/MEB_2015-06-02.13-32-04_apply_inc.log -------------------------------------------------------------------- Backup Config Options: -------------------------------------------------------------------- datadir = /root/2015-06-02_12-20-00/datadir innodb_data_home_dir = /root/2015-06-02_12-20-00/datadir innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /root/2015-06-02_12-20-00/datadir innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb mysqlbackup: INFO: Creating 14 buffers each of size 16908288. 150602 13:32:04 mysqlbackup: INFO: Apply-Incremental-Pages operation starts with following threads 1 read-threads 1 write-threads mysqlbackup: INFO: Could not find binlog index file. binlogs will not be copied for this backup. Point-In-Time-Recovery will not be possible. If this is online backup then server may not have started with --log-bin. You may specify its location with --log-bin-index option. 150602 13:32:04 mysqlbackup: INFO: Starting deletion of obsolete ibd files in backup-dir... 150602 13:32:04 mysqlbackup: INFO: Deleting dropped ibd files. 150602 13:32:04 mysqlbackup: INFO: Deletion of obsolete ibd files in backup-dir is completed. 150602 13:32:04 mysqlbackup: INFO: Deleting non-innodb files in backup-dir... 150602 13:32:04 mysqlbackup: INFO: Applying diff pages from `/root/2015-06-02_13-17-52/datadir/ibdata1` to `/root/2015-06-02_12-20-00/datadir/ibdata1`. mysqlbackup: Progress in MB: 200 150602 13:32:13 mysqlbackup: INFO: Applying incremental pages to innodb data files... 150602 13:32:13 mysqlbackup: INFO: Starting to copy all non-innodb files in subdirectories of ‘/root/2015-06-02_13-17-52/datadir‘ 150602 13:32:13 mysqlbackup: INFO: Copying the database directory ‘9tong_ur‘ 150602 13:32:15 mysqlbackup: INFO: Copying the database directory ‘9tong_user‘ 150602 13:32:15 mysqlbackup: INFO: Copying the database directory ‘aclocal‘ 150602 13:32:15 mysqlbackup: INFO: Copying the database directory ‘mysql‘ 150602 13:32:16 mysqlbackup: INFO: Copying the database directory ‘performance_schema‘ 150602 13:32:16 mysqlbackup: INFO: Copying the database directory ‘ps_helper‘ 150602 13:32:17 mysqlbackup: INFO: Copying the database directory ‘sys‘ 150602 13:32:18 mysqlbackup: INFO: Copying the database directory ‘test‘ 150602 13:32:18 mysqlbackup: INFO: Copying the database directory ‘zxl‘ 150602 13:32:18 mysqlbackup: INFO: Completing the copy of all non-innodb files. 150602 13:32:18 mysqlbackup: INFO: Copying server configuration files to backup_dir. 150602 13:32:19 mysqlbackup: INFO: Apply-Incremental-Pages operation completed successfully. mysqlbackup: INFO: Creating 14 buffers each of size 65536. 150602 13:32:19 mysqlbackup: INFO: Apply-log operation starts with following threads 1 read-threads 1 process-threads mysqlbackup: INFO: Using up to 100 MB of memory. 150602 13:32:20 mysqlbackup: INFO: ibbackup_logfile‘s creation parameters: start lsn 171829647360, end lsn 171829647523, start checkpoint 171829647523. InnoDB: Doing recovery: scanned up to log sequence number 171829647523 mysqlbackup: INFO: InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 mysqlbackup: INFO: InnoDB: Setting log file size to 4294967296 InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 mysqlbackup: INFO: InnoDB: Setting log file size to 4294967296 InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 150602 13:34:29 mysqlbackup: INFO: We were able to parse ibbackup_logfile up to lsn 171829647523. mysqlbackup: INFO: Last MySQL binlog file position 0 791363474, file name mysql-bin.000023 150602 13:34:29 mysqlbackup: INFO: The first data file is ‘/root/2015-06-02_12-20-00/datadir/ibdata1‘ and the new created log files are at ‘/root/2015-06-02_12-20-00/datadir‘ 150602 13:34:29 mysqlbackup: INFO: Apply-log operation completed successfully. 150602 13:34:29 mysqlbackup: INFO: Full backup prepared for recovery successfully. mysqlbackup completed OK! 3、检测匹配释放第二次的增量备份 [[email protected] meta]# mysqlbackup --backup-dir=/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root/2015-06-02_16-37-40/ apply-incremental-backup MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... mysqlbackup --backup-dir=/root/2015-06-02_12-20-00/ --incremental-backup-dir=/root/2015-06-02_16-37-40/ apply-incremental-backup mysqlbackup: INFO: IMPORTANT: Please check that mysqlbackup run completes successfully. At the end of a successful ‘apply-incremental-backup‘ run mysqlbackup prints "mysqlbackup completed OK!". 150602 17:18:03 mysqlbackup: INFO: MEB logfile created at /root/2015-06-02_12-20-00/meta/MEB_2015-06-02.17-18-03_apply_inc.log -------------------------------------------------------------------- Backup Config Options: -------------------------------------------------------------------- datadir = /root/2015-06-02_12-20-00/datadir innodb_data_home_dir = /root/2015-06-02_12-20-00/datadir innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /root/2015-06-02_12-20-00/datadir innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb mysqlbackup: INFO: Creating 14 buffers each of size 16908288. 150602 17:18:03 mysqlbackup: INFO: Apply-Incremental-Pages operation starts with following threads 1 read-threads 1 write-threads mysqlbackup: INFO: Could not find binlog index file. binlogs will not be copied for this backup. Point-In-Time-Recovery will not be possible. If this is online backup then server may not have started with --log-bin. You may specify its location with --log-bin-index option. 150602 17:18:03 mysqlbackup: INFO: Starting deletion of obsolete ibd files in backup-dir... 150602 17:18:03 mysqlbackup: INFO: Deleting dropped ibd files. 150602 17:18:03 mysqlbackup: INFO: Deletion of obsolete ibd files in backup-dir is completed. 150602 17:18:03 mysqlbackup: INFO: Deleting non-innodb files in backup-dir... 150602 17:18:03 mysqlbackup: INFO: Applying diff pages from `/root/2015-06-02_16-37-40/datadir/ibdata1` to `/root/2015-06-02_12-20-00/datadir/ibdata1`. 150602 17:18:03 mysqlbackup: INFO: Applying incremental pages to innodb data files... 150602 17:18:03 mysqlbackup: INFO: Starting to copy all non-innodb files in subdirectories of ‘/root/2015-06-02_16-37-40/datadir‘ 150602 17:18:03 mysqlbackup: INFO: Copying the database directory ‘9tong_ur‘ 150602 17:18:05 mysqlbackup: INFO: Copying the database directory ‘9tong_user‘ 150602 17:18:05 mysqlbackup: INFO: Copying the database directory ‘aclocal‘ 150602 17:18:05 mysqlbackup: INFO: Copying the database directory ‘mysql‘ 150602 17:18:06 mysqlbackup: INFO: Copying the database directory ‘performance_schema‘ 150602 17:18:06 mysqlbackup: INFO: Copying the database directory ‘ps_helper‘ 150602 17:18:07 mysqlbackup: INFO: Copying the database directory ‘sys‘ 150602 17:18:07 mysqlbackup: INFO: Copying the database directory ‘test‘ 150602 17:18:07 mysqlbackup: INFO: Copying the database directory ‘zxl‘ 150602 17:18:07 mysqlbackup: INFO: Completing the copy of all non-innodb files. 150602 17:18:07 mysqlbackup: INFO: Copying server configuration files to backup_dir. 150602 17:18:08 mysqlbackup: INFO: Apply-Incremental-Pages operation completed successfully. mysqlbackup: INFO: Creating 14 buffers each of size 65536. 150602 17:18:08 mysqlbackup: INFO: Apply-log operation starts with following threads 1 read-threads 1 process-threads mysqlbackup: INFO: Using up to 100 MB of memory. 150602 17:18:09 mysqlbackup: INFO: ibbackup_logfile‘s creation parameters: start lsn 171829666304, end lsn 171829666420, start checkpoint 171829666420. InnoDB: Doing recovery: scanned up to log sequence number 171829666420 mysqlbackup: INFO: InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 mysqlbackup: INFO: InnoDB: Setting log file size to 4294967296 InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 mysqlbackup: INFO: InnoDB: Setting log file size to 4294967296 InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 150602 17:20:11 mysqlbackup: INFO: We were able to parse ibbackup_logfile up to lsn 171829666420. mysqlbackup: INFO: Last MySQL binlog file position 0 791363474, file name mysql-bin.000023 150602 17:20:11 mysqlbackup: INFO: The first data file is ‘/root/2015-06-02_12-20-00/datadir/ibdata1‘ and the new created log files are at ‘/root/2015-06-02_12-20-00/datadir‘ 150602 17:20:11 mysqlbackup: INFO: Apply-log operation completed successfully. 150602 17:20:11 mysqlbackup: INFO: Full backup prepared for recovery successfully. mysqlbackup completed OK! 4、进行物理文件复制 [[email protected] meta]# mysqlbackup --defaults-file=/etc/my.cnf --datadir=/9tong/mysql/data/3003/ --backup-dir=/root/2015-06-02_12-20-00/ copy-back MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... mysqlbackup --defaults-file=/etc/my.cnf --datadir=/9tong/mysql/data/3003/ --backup-dir=/root/2015-06-02_12-20-00/ copy-back mysqlbackup: INFO: IMPORTANT: Please check that mysqlbackup run completes successfully. At the end of a successful ‘copy-back‘ run mysqlbackup prints "mysqlbackup completed OK!". 150602 17:21:54 mysqlbackup: INFO: MEB logfile created at /root/2015-06-02_12-20-00/meta/MEB_2015-06-02.17-21-54_copy_back.log mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_data_file_path parameter might have a different default. In that case you need to add ‘innodb_data_file_path=ibdata1:12M:autoextend‘ to the target server configuration. mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_log_files_in_group parameter might have a different default. In that case you need to add ‘innodb_log_files_in_group=2‘ to the target server configuration. mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_log_file_size parameter might have a different default. In that case you need to add ‘innodb_log_file_size=4294967296‘ to the target server configuration. -------------------------------------------------------------------- Server Repository Options: -------------------------------------------------------------------- datadir = /9tong/mysql/data/3003/ innodb_data_home_dir = /9tong/mysql/data/3003/ innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /9tong/mysql/data/3003/ innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = Null innodb_checksum_algorithm = innodb -------------------------------------------------------------------- Backup Config Options: -------------------------------------------------------------------- datadir = /root/2015-06-02_12-20-00/datadir innodb_data_home_dir = /root/2015-06-02_12-20-00/datadir innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /root/2015-06-02_12-20-00/datadir innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb mysqlbackup: INFO: Creating 14 buffers each of size 16777216. 150602 17:21:54 mysqlbackup: INFO: Copy-back operation starts with following threads 1 read-threads 1 write-threads mysqlbackup: INFO: Could not find binlog index file. binlogs will not be copied for this backup. Point-In-Time-Recovery will not be possible. If this is online backup then server may not have started with --log-bin. You may specify its location with --log-bin-index option. 150602 17:21:54 mysqlbackup: INFO: Copying /root/2015-06-02_12-20-00/datadir/ibdata1 (to ‘/9tong/mysql/data/3003‘). mysqlbackup: Progress in MB: 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 5200 5400 5600 5800 6000 6200 6400 6600 6800 7000 7200 7400 7600 7800 8000 8200 8400 8600 8800 9000 9200 9400 9600 9800 10000 10200 10400 10600 10800 11000 11200 11400 11600 11800 12000 12200 12400 12600 12800 13000 13200 13400 13600 13800 14000 14200 14400 14600 14800 15000 15200 15400 15600 15800 16000 16200 16400 16600 16800 17000 17200 17400 17600 17800 18000 18200 18400 18600 18800 19000 19200 150602 17:30:21 mysqlbackup: INFO: Copying the database directory ‘9tong_ur‘ 150602 17:30:24 mysqlbackup: INFO: Copying the database directory ‘9tong_user‘ 150602 17:30:24 mysqlbackup: INFO: Copying the database directory ‘aclocal‘ 150602 17:30:24 mysqlbackup: INFO: Copying the database directory ‘mysql‘ 150602 17:30:25 mysqlbackup: INFO: Copying the database directory ‘performance_schema‘ 150602 17:30:26 mysqlbackup: INFO: Copying the database directory ‘ps_helper‘ 150602 17:30:26 mysqlbackup: INFO: Copying the database directory ‘sys‘ 150602 17:30:27 mysqlbackup: INFO: Copying the database directory ‘test‘ 150602 17:30:27 mysqlbackup: INFO: Copying the database directory ‘zxl‘ 150602 17:30:27 mysqlbackup: INFO: Completing the copy of all non-innodb files. 150602 17:30:27 mysqlbackup: INFO: Copying the log file ‘ib_logfile0‘ mysqlbackup: Progress in MB: 19400 19600 19800 20000 20200 20400 20600 20800 21000 21200 21400 21600 21800 22000 22200 22400 22600 22800 23000 23200 150602 17:32:21 mysqlbackup: INFO: Copying the log file ‘ib_logfile1‘ mysqlbackup: Progress in MB: 23400 23600 23800 24000 24200 24400 24600 24800 25000 25200 25400 25600 25800 26000 26200 26400 26600 26800 27000 27200 27400 150602 17:33:23 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /9tong/mysql/data/3003/ 150602 17:33:23 mysqlbackup: INFO: Copy-back operation completed successfully. 150602 17:33:23 mysqlbackup: INFO: Finished copying backup files to ‘/9tong/mysql/data/3003/‘ mysqlbackup completed OK! with 3 warnings [[email protected] meta]# mysqlbackup --defaults-file=/etc/my.cnf --datadir=/9tong/mysql/data/3003/ --backup-dir=/root/2015-06-02_12-20-00/ copy-back MySQL Enterprise Backup version 3.11.1 Linux-2.6.18-194.el5-x86_64 [2014/11/04] Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved. mysqlbackup: INFO: Starting with following command line ... mysqlbackup --defaults-file=/etc/my.cnf --datadir=/9tong/mysql/data/3003/ --backup-dir=/root/2015-06-02_12-20-00/ copy-back mysqlbackup: INFO: IMPORTANT: Please check that mysqlbackup run completes successfully. At the end of a successful ‘copy-back‘ run mysqlbackup prints "mysqlbackup completed OK!". 150602 17:37:26 mysqlbackup: INFO: MEB logfile created at /root/2015-06-02_12-20-00/meta/MEB_2015-06-02.17-37-26_copy_back.log mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_data_file_path parameter might have a different default. In that case you need to add ‘innodb_data_file_path=ibdata1:12M:autoextend‘ to the target server configuration. mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_log_files_in_group parameter might have a different default. In that case you need to add ‘innodb_log_files_in_group=2‘ to the target server configuration. mysqlbackup: WARNING: If you restore to a server of a different version, the innodb_log_file_size parameter might have a different default. In that case you need to add ‘innodb_log_file_size=4294967296‘ to the target server configuration. -------------------------------------------------------------------- Server Repository Options: -------------------------------------------------------------------- datadir = /9tong/mysql/data/3003/ innodb_data_home_dir = /9tong/mysql/data/3003/ innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /9tong/mysql/data/3003/ innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = Null innodb_checksum_algorithm = innodb -------------------------------------------------------------------- Backup Config Options: -------------------------------------------------------------------- datadir = /root/2015-06-02_12-20-00/datadir innodb_data_home_dir = /root/2015-06-02_12-20-00/datadir innodb_data_file_path = ibdata1:12M:autoextend innodb_log_group_home_dir = /root/2015-06-02_12-20-00/datadir innodb_log_files_in_group = 2 innodb_log_file_size = 4294967296 innodb_page_size = 16384 innodb_checksum_algorithm = innodb mysqlbackup: INFO: Creating 14 buffers each of size 16777216. 150602 17:37:26 mysqlbackup: INFO: Copy-back operation starts with following threads 1 read-threads 1 write-threads mysqlbackup: INFO: Could not find binlog index file. binlogs will not be copied for this backup. Point-In-Time-Recovery will not be possible. If this is online backup then server may not have started with --log-bin. You may specify its location with --log-bin-index option. 150602 17:37:26 mysqlbackup: INFO: Copying /root/2015-06-02_12-20-00/datadir/ibdata1 (to ‘/9tong/mysql/data/3003‘). mysqlbackup: Progress in MB: 200 400 600 800 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 3200 3400 3600 3800 4000 4200 4400 4600 4800 5000 5200 5400 5600 5800 6000 6200 6400 6600 6800 7000 7200 7400 7600 7800 8000 8200 8400 8600 8800 9000 9200 9400 9600 9800 10000 10200 10400 10600 10800 11000 11200 11400 11600 11800 12000 12200 12400 12600 12800 13000 13200 13400 13600 13800 14000 14200 14400 14600 14800 15000 15200 15400 15600 15800 16000 16200 16400 16600 16800 17000 17200 17400 17600 17800 18000 18200 18400 18600 18800 19000 19200 150602 17:45:52 mysqlbackup: INFO: Copying the database directory ‘9tong_ur‘ 150602 17:45:54 mysqlbackup: INFO: Copying the database directory ‘9tong_user‘ 150602 17:45:54 mysqlbackup: INFO: Copying the database directory ‘aclocal‘ 150602 17:45:54 mysqlbackup: INFO: Copying the database directory ‘mysql‘ 150602 17:45:55 mysqlbackup: INFO: Copying the database directory ‘performance_schema‘ 150602 17:45:55 mysqlbackup: INFO: Copying the database directory ‘ps_helper‘ 150602 17:45:56 mysqlbackup: INFO: Copying the database directory ‘sys‘ 150602 17:45:57 mysqlbackup: INFO: Copying the database directory ‘test‘ 150602 17:45:57 mysqlbackup: INFO: Copying the database directory ‘zxl‘ 150602 17:45:57 mysqlbackup: INFO: Completing the copy of all non-innodb files. 150602 17:45:57 mysqlbackup: INFO: Copying the log file ‘ib_logfile0‘ mysqlbackup: Progress in MB: 19400 19600 19800 20000 20200 20400 20600 20800 21000 21200 21400 21600 21800 22000 22200 22400 22600 22800 23000 23200 150602 17:47:50 mysqlbackup: INFO: Copying the log file ‘ib_logfile1‘ mysqlbackup: Progress in MB: 23400 23600 23800 24000 24200 24400 24600 24800 25000 25200 25400 25600 25800 26000 26200 26400 26600 26800 27000 27200 27400 150602 17:49:46 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /9tong/mysql/data/3003/ 150602 17:49:46 mysqlbackup: INFO: Copy-back operation completed successfully. 150602 17:49:46 mysqlbackup: INFO: Finished copying backup files to ‘/9tong/mysql/data/3003/‘ mysqlbackup completed OK! with 3 warnings 数据验证 mysql> show tables; +-----------------------------+ | Tables_in_9tong_user | +-----------------------------+ | account_extension | | cast_users | | industry | | news_cast | | news_cast_history | | notactive_user | | product_info_temp | | sys_users | | sys_verify | | user_account | | user_account2016 | | user_active_15 | | user_active_30 | | user_active_60 | | user_bargain | | user_bid | | user_education | | user_info | | user_purchase | | user_purchase_choose | | user_purchase_follow | | user_purchase_message_click | | user_remark | | user_sdr | | user_sdr_visitor | | user_verify_sms | | user_visitor | | user_works | +-----------------------------+ 删除的3张表都出现了,说明增量备份成功。 注:第二次增量备份的文件也是释放到全备文件里面,(首先会进入事物日志,然后是表空间),因为第一次的增量备份后,全库里面已经有了第一次的LSN点,所以二次还原的时间同样指向全备文件里面使LSN点在外后增加。
结论:增量备份导入所花费的时间和全量差不多,而且增量的越多,细节处理也越多。因此建议是全量做一次,增量少做。切记导入数据还原后。注意权限的修改,及重启数据库生效。
时间: 2024-10-13 20:24:09