首页 > 其他分享 >xtrabackup2.4 增量备份

xtrabackup2.4 增量备份

时间:2023-01-12 19:47:39浏览次数:52  
标签:01 -- 18 备份 230112 xtrabackup xtrabackup2.4 增量 data

创建备份用户

mysql> CREATE USER 'bkpuser'@'localhost' IDENTIFIED BY 's3cret';
mysql> GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'bkpuser'@'localhost';
mysql> FLUSH PRIVILEGES;

创建测试数据

创建数据

mysql> CREATE DATABASE test;
mysql> CREATE TABLE test.messages (message VARCHAR(250));
mysql> INSERT INTO test.messages VALUES ('hello');

查询数据

mysql> select * from messages;
+---------+
| message |
+---------+
| hello   |
+---------+
1 row in set (0.00 sec)

全量备份数据

备份数据

# xtrabackup  --backup  --slave-info  --host="localhost"  --port=3306 --user="bkpuser" --password="s3cret" --socket="/data/mysql/mysql.sock"  --parallel=2 --target-dir="/data/xtrabackup/base"

查看备份信息

# ls -l /data/xtrabackup/base
total 12336
-rw-r----- 1 root root      487 Jan 12 18:29 backup-my.cnf
-rw-r----- 1 root root      436 Jan 12 18:29 ib_buffer_pool
-rw-r----- 1 root root 12582912 Jan 12 18:29 ibdata1
drwxr-x--- 2 root root     4096 Jan 12 18:29 mysql
drwxr-x--- 2 root root     4096 Jan 12 18:29 performance_schema
drwxr-x--- 2 root root    12288 Jan 12 18:29 sys
drwxr-x--- 2 root root     4096 Jan 12 18:29 test
-rw-r----- 1 root root       21 Jan 12 18:29 xtrabackup_binlog_info
-rw-r----- 1 root root      135 Jan 12 18:29 xtrabackup_checkpoints
-rw-r----- 1 root root      589 Jan 12 18:29 xtrabackup_info
-rw-r----- 1 root root     2560 Jan 12 18:29 xtrabackup_logfile
-rw-r----- 1 root root        0 Jan 12 18:29 xtrabackup_slave_info

查看xtrabackup_checkpoints

# cat /data/xtrabackup/base/xtrabackup_checkpoints 
backup_type = full-backuped
from_lsn = 0
to_lsn = 2768955
last_lsn = 2768964
compact = 0
recover_binlog_info = 0
flushed_lsn = 2768964

增量备份数据

新增数据inc1

mysql> INSERT INTO test.messages VALUES ('inc1');
Query OK, 1 row affected (0.00 sec)

mysql> select * from messages;
+---------+
| message |
+---------+
| hello   |
| inc1    |
+---------+
2 rows in set (0.00 sec)

增量备份一

备份数据inc1

# xtrabackup  --backup  --slave-info  --host="localhost"  --port=3306 --user="bkpuser" --password="s3cret" --socket="/data/mysql/mysql.sock"  --parallel=2  --target-dir=/data/xtrabackup/inc1 --incremental-basedir=/data/xtrabackup/base
xtrabackup: recognized server arguments: --parallel=2 
xtrabackup: recognized client arguments: --backup=1 --slave-info=1 --host=localhost --port=3306 --user=bkpuser --password=* --socket=/data/mysql/mysql.sock --target-dir=/data/xtrabackup/inc1 --incremental-basedir=/data/xtrabackup/base 
230112 18:36:00  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;host=localhost;port=3306;mysql_socket=/data/mysql/mysql.sock' as 'bkpuser'  (using password: YES).
Failed to connect to MySQL server as DBD::mysql module is not installed at - line 1327.
230112 18:36:00 Connecting to MySQL server host: localhost, user: bkpuser, password: set, port: 3306, socket: /data/mysql/mysql.sock
Using server version 5.7.40-log
xtrabackup version 2.4.27 based on MySQL server 5.7.40 Linux (x86_64) (revision id: aae8e82)
incremental backup from 2768955 is enabled.
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysql/data/
xtrabackup: open files limit requested 0, set to 100000
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 50331648
InnoDB: Number of pools: 1
230112 18:36:00 >> log scanned up to (2769355)
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 24 for test/messages, old maximum was 0
xtrabackup: using the full scan for incremental backup
xtrabackup: Starting 2 threads for parallel data files transfer
230112 18:36:00 [02] Copying ./test/messages.ibd to /data/xtrabackup/inc1/test/messages.ibd.delta
230112 18:36:00 [02]        ...done
230112 18:36:00 [01] Copying ./ibdata1 to /data/xtrabackup/inc1/ibdata1.delta
230112 18:36:00 [01]        ...done
230112 18:36:00 [02] Copying ./mysql/time_zone_transition_type.ibd to /data/xtrabackup/inc1/mysql/time_zone_transition_type.ibd.delta
230112 18:36:00 [02]        ...done
....
230112 18:36:01 [01] Copying ./sys/x@0024ps_digest_95th_percentile_by_avg_us.frm to /data/xtrabackup/inc1/sys/x@0024ps_digest_95th_percentile_by_avg_us.frm
230112 18:36:01 [01]        ...done
230112 18:36:01 Finished backing up non-InnoDB tables and files
230112 18:36:01 [00] Writing /data/xtrabackup/inc1/xtrabackup_slave_info
230112 18:36:01 [00]        ...done
230112 18:36:01 [00] Writing /data/xtrabackup/inc1/xtrabackup_binlog_info
230112 18:36:01 [00]        ...done
230112 18:36:01 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '2769346'
xtrabackup: Stopping log copying thread.
.230112 18:36:01 >> log scanned up to (2769355)

230112 18:36:01 Executing UNLOCK TABLES
230112 18:36:01 All tables unlocked
230112 18:36:01 [00] Copying ib_buffer_pool to /data/xtrabackup/inc1/ib_buffer_pool
230112 18:36:01 [00]        ...done
230112 18:36:01 Backup created in directory '/data/xtrabackup/inc1/'
MySQL binlog position: filename 'mysql-bin.000005', position '416'
230112 18:36:01 [00] Writing /data/xtrabackup/inc1/backup-my.cnf
230112 18:36:01 [00]        ...done
230112 18:36:01 [00] Writing /data/xtrabackup/inc1/xtrabackup_info
230112 18:36:01 [00]        ...done
xtrabackup: Transaction log of lsn (2769346) to (2769355) was copied.
230112 18:36:02 completed OK!

查看inc1 xtrabackup_checkpoints

# cat /data/xtrabackup/inc1/xtrabackup_checkpoints 
backup_type = incremental
from_lsn = 2768955
to_lsn = 2769346
last_lsn = 2769355
compact = 0
recover_binlog_info = 0
flushed_lsn = 2769355

新增数据inc2

mysql> INSERT INTO test.messages VALUES ('inc2');
Query OK, 1 row affected (0.00 sec)

mysql> select * from messages;
+---------+
| message |
+---------+
| hello   |
| inc1    |
| inc2    |
+---------+
3 rows in set (0.00 sec)

增量备份二

备份数据inc2

# xtrabackup  --backup  --slave-info  --host="localhost"  --port=3306 --user="bkpuser" --password="s3cret" --socket="/data/mysql/mysql.sock"  --parallel=2  --target-dir=/data/xtrabackup/inc2 --incremental-basedir=/data/xtrabackup/inc1
xtrabackup: recognized server arguments: --parallel=2 
xtrabackup: recognized client arguments: --backup=1 --slave-info=1 --host=localhost --port=3306 --user=bkpuser --password=* --socket=/data/mysql/mysql.sock --target-dir=/data/xtrabackup/inc2 --incremental-basedir=/data/xtrabackup/inc1 
230112 18:39:39  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;host=localhost;port=3306;mysql_socket=/data/mysql/mysql.sock' as 'bkpuser'  (using password: YES).
Failed to connect to MySQL server as DBD::mysql module is not installed at - line 1327.
230112 18:39:39 Connecting to MySQL server host: localhost, user: bkpuser, password: set, port: 3306, socket: /data/mysql/mysql.sock
Using server version 5.7.40-log
xtrabackup version 2.4.27 based on MySQL server 5.7.40 Linux (x86_64) (revision id: aae8e82)
incremental backup from 2769346 is enabled.
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysql/data/
xtrabackup: open files limit requested 0, set to 100000
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 50331648
InnoDB: Number of pools: 1
230112 18:39:39 >> log scanned up to (2769713)
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 24 for test/messages, old maximum was 0
xtrabackup: using the full scan for incremental backup
xtrabackup: Starting 2 threads for parallel data files transfer
230112 18:39:40 [01] Copying ./ibdata1 to /data/xtrabackup/inc2/ibdata1.delta
230112 18:39:40 [02] Copying ./test/messages.ibd to /data/xtrabackup/inc2/test/messages.ibd.delta
230112 18:39:40 [02]        ...done
230112 18:39:40 [01]        ...done
....
230112 18:39:41 [01] Copying ./sys/x@0024ps_digest_95th_percentile_by_avg_us.frm to /data/xtrabackup/inc2/sys/x@0024ps_digest_95th_percentile_by_avg_us.frm
230112 18:39:41 [01]        ...done
230112 18:39:41 Finished backing up non-InnoDB tables and files
230112 18:39:41 [00] Writing /data/xtrabackup/inc2/xtrabackup_slave_info
230112 18:39:41 [00]        ...done
230112 18:39:41 [00] Writing /data/xtrabackup/inc2/xtrabackup_binlog_info
230112 18:39:41 [00]        ...done
230112 18:39:41 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '2769704'
xtrabackup: Stopping log copying thread.
.230112 18:39:41 >> log scanned up to (2769713)

230112 18:39:41 Executing UNLOCK TABLES
230112 18:39:41 All tables unlocked
230112 18:39:41 [00] Copying ib_buffer_pool to /data/xtrabackup/inc2/ib_buffer_pool
230112 18:39:41 [00]        ...done
230112 18:39:41 Backup created in directory '/data/xtrabackup/inc2/'
MySQL binlog position: filename 'mysql-bin.000005', position '678'
230112 18:39:41 [00] Writing /data/xtrabackup/inc2/backup-my.cnf
230112 18:39:41 [00]        ...done
230112 18:39:41 [00] Writing /data/xtrabackup/inc2/xtrabackup_info
230112 18:39:41 [00]        ...done
xtrabackup: Transaction log of lsn (2769704) to (2769713) was copied.
230112 18:39:41 completed OK!

查看inc2 xtrabackup_checkpoints

# cat /data/xtrabackup/inc2/xtrabackup_checkpoints 
backup_type = incremental
from_lsn = 2769346
to_lsn = 2769704
last_lsn = 2769713
compact = 0
recover_binlog_info = 0
flushed_lsn = 2769713

清除测试数据

查看数据

mysql> select * from messages;
+---------+
| message |
+---------+
| hello   |
| inc1    |
| inc2    |
+---------+
3 rows in set (0.00 sec)

删除测试数据

mysql> drop table messages;
Query OK, 0 rows affected (0.00 sec)

停止mysql服务

# systemctl stop mysqld

还原全量数据

Preparing base

# xtrabackup --prepare --apply-log-only --target-dir=/data/xtrabackup/base/
xtrabackup: recognized server arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:12M:autoextend --innodb_log_files_in_group=2 --innodb_log_file_size=50331648 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=./ --innodb_undo_tablespaces=0 --server-id=0 --redo-log-version=1 
xtrabackup: recognized client arguments: --prepare=1 --apply-log-only=1 --target-dir=/data/xtrabackup/base/ 
xtrabackup version 2.4.27 based on MySQL server 5.7.40 Linux (x86_64) (revision id: aae8e82)
xtrabackup: cd to /data/xtrabackup/base/
xtrabackup: This target seems to be not prepared yet.
InnoDB: Number of pools: 1
xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(2768955)
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = .
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = .
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
InnoDB: PUNCH HOLE support available
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Uses event mutexes
InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
InnoDB: Compressed tables use zlib 1.2.12
InnoDB: Number of pools: 1
InnoDB: Using CPU crc32 instructions
InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M
InnoDB: Completed initialization of buffer pool
InnoDB: page_cleaner coordinator priority: -20
InnoDB: Highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 2768955
InnoDB: Doing recovery: scanned up to log sequence number 2768964 (0%)
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: xtrabackup: Last MySQL binlog file position 2875, file name mysql-bin.000003
InnoDB: xtrabackup: Last MySQL binlog file position 2875, file name mysql-bin.000003

xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 2768973
InnoDB: Number of pools: 1
230112 18:46:55 completed OK!

copy-back base

# xtrabackup --copy-back --target-dir=/data/xtrabackup/base/ --datadir=/data/xtrabackup/base-copy-back
xtrabackup: recognized server arguments: --datadir=/data/xtrabackup/base-copy-back 
xtrabackup: recognized client arguments: --copy-back=1 --target-dir=/data/xtrabackup/base/ 
xtrabackup version 2.4.27 based on MySQL server 5.7.40 Linux (x86_64) (revision id: aae8e82)
230112 18:58:21 [01] Copying ibdata1 to /data/xtrabackup/base-copy-back/ibdata1
230112 18:58:21 [01]        ...done
230112 18:58:21 [01] Copying ./xtrabackup_info to /data/xtrabackup/base-copy-back/xtrabackup_info
230112 18:58:21 [01]        ...done
230112 18:58:21 [01] Copying ./test/messages.ibd to /data/xtrabackup/base-copy-back/test/messages.ibd
230112 18:58:21 [01]        ...done
230112 18:58:21 [01] Copying ./test/messages.frm to /data/xtrabackup/base-copy-back/test/messages.frm
230112 18:58:21 [01]        ...done
230112 18:58:21 [01] Copying ./test/db.opt to /data/xtrabackup/base-copy-back/test/db.opt
230112 18:58:21 [01]        ...done
230112 18:58:21 [01] Copying ./mysql/user.MYI to /data/xtrabackup/base-copy-back/mysql/user.MYI
230112 18:58:21 [01]        ...done
230112 18:58:21 [01] Copying ./mysql/user.frm to /data/xtrabackup/base-copy-back/mysql/user.frm
230112 18:58:21 [01]        ...done
.....
230112 18:58:21 [01] Copying ./sys/x@0024ps_digest_95th_percentile_by_avg_us.frm to /data/xtrabackup/base-copy-back/sys/x@0024ps_digest_95th_percentile_by_avg_us.frm
230112 18:58:21 [01]        ...done
230112 18:58:21 [01] Copying ./xtrabackup_binlog_pos_innodb to /data/xtrabackup/base-copy-back/xtrabackup_binlog_pos_innodb
230112 18:58:21 [01]        ...done
230112 18:58:21 completed OK!

同步数据

# rsync -avrP /data/xtrabackup/base-copy-back/ /data/mysql/data/

修改属组

# chown -R mysql:mysql /data/mysql/data/

启动mysql

# systemctl restart mysqld

查询数据

mysql> select * from messages;
+---------+
| message |
+---------+
| hello   |
+---------+
1 row in set (0.01 sec)

还原增量1数据

Preparing 增量1

# xtrabackup --prepare --apply-log-only --target-dir=/data/xtrabackup/base --incremental-dir=/data/xtrabackup/inc1
xtrabackup: recognized server arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:12M:autoextend --innodb_log_files_in_group=2 --innodb_log_file_size=50331648 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=./ --innodb_undo_tablespaces=0 --server-id=0 --redo-log-version=1 
xtrabackup: recognized client arguments: --prepare=1 --apply-log-only=1 --target-dir=/data/xtrabackup/base --incremental-dir=/data/xtrabackup/inc1 
xtrabackup version 2.4.27 based on MySQL server 5.7.40 Linux (x86_64) (revision id: aae8e82)
incremental backup from 2768955 is enabled.
xtrabackup: cd to /data/xtrabackup/base/
xtrabackup: This target seems to be already prepared with --apply-log-only.
InnoDB: Number of pools: 1
xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(2769346)
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = /data/xtrabackup/inc1/
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 24 for test/messages, old maximum was 0
xtrabackup: page size for /data/xtrabackup/inc1//ibdata1.delta is 16384 bytes space id is 0
Applying /data/xtrabackup/inc1//ibdata1.delta to ./ibdata1...
xtrabackup: page size for /data/xtrabackup/inc1//test/messages.ibd.delta is 16384 bytes space id is 24
Applying /data/xtrabackup/inc1//test/messages.ibd.delta to ./test/messages.ibd...
xtrabackup: page size for /data/xtrabackup/inc1//mysql/innodb_table_stats.ibd.delta is 16384 bytes space id is 13
Applying /data/xtrabackup/inc1//mysql/innodb_table_stats.ibd.delta to ./mysql/innodb_table_stats.ibd...
xtrabackup: page size for /data/xtrabackup/inc1//mysql/time_zone_name.ibd.delta is 16384 bytes space id is 8
Applying /data/xtrabackup/inc1//mysql/time_zone_name.ibd.delta to ./mysql/time_zone_name.ibd...
xtrabackup: page size for /data/xtrabackup/inc1//mysql/help_category.ibd.delta is 16384 bytes space id is 5
...
230112 18:49:24 [01] Copying /data/xtrabackup/inc1/sys/x@0024ps_digest_95th_percentile_by_avg_us.frm to ./sys/x@0024ps_digest_95th_percentile_by_avg_us.frm
230112 18:49:24 [01]        ...done
230112 18:49:24 [00] Copying /data/xtrabackup/inc1//xtrabackup_binlog_info to ./xtrabackup_binlog_info
230112 18:49:24 [00]        ...done
230112 18:49:24 [00] Copying /data/xtrabackup/inc1//xtrabackup_slave_info to ./xtrabackup_slave_info
230112 18:49:24 [00]        ...done
230112 18:49:24 [00] Copying /data/xtrabackup/inc1//xtrabackup_info to ./xtrabackup_info
230112 18:49:24 [00]        ...done
230112 18:49:24 completed OK!

copy-back base-inc1

# xtrabackup --copy-back --target-dir=/data/xtrabackup/base/ --datadir=/data/xtrabackup/base-copy-back-inc1
xtrabackup: recognized server arguments: --datadir=/data/xtrabackup/base-copy-back-inc1 
xtrabackup: recognized client arguments: --copy-back=1 --target-dir=/data/xtrabackup/base/ 
xtrabackup version 2.4.27 based on MySQL server 5.7.40 Linux (x86_64) (revision id: aae8e82)
230112 19:18:13 [01] Copying ibdata1 to /data/xtrabackup/base-copy-back-inc1/ibdata1
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./xtrabackup_info to /data/xtrabackup/base-copy-back-inc1/xtrabackup_info
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./test/messages.ibd to /data/xtrabackup/base-copy-back-inc1/test/messages.ibd
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./test/messages.frm to /data/xtrabackup/base-copy-back-inc1/test/messages.frm
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./test/db.opt to /data/xtrabackup/base-copy-back-inc1/test/db.opt
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./mysql/user.MYI to /data/xtrabackup/base-copy-back-inc1/mysql/user.MYI
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./mysql/user.frm to /data/xtrabackup/base-copy-back-inc1/mysql/user.frm
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./mysql/time_zone_transition_type.ibd to /data/xtrabackup/base-copy-back-inc1/mysql/time_zone_transition_type.ibd
230112 19:18:13 [01]        ...done
...
230112 19:18:13 [01] Copying ./sys/x@0024ps_digest_95th_percentile_by_avg_us.frm to /data/xtrabackup/base-copy-back-inc1/sys/x@0024ps_digest_95th_percentile_by_avg_us.frm
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./xtrabackup_binlog_pos_innodb to /data/xtrabackup/base-copy-back-inc1/xtrabackup_binlog_pos_innodb
230112 19:18:13 [01]        ...done
230112 19:18:13 completed OK!

停止mysql

# systemctl stop mysqld

同步数据

# rsync -avrP /data/xtrabackup/base-copy-back-inc1/ /data/mysql/data/

修改属组

# chown -R mysql:mysql /data/mysql/data/

重启mysql

# systemctl restart mysqld

查询数据

mysql> select * from messages;
+---------+
| message |
+---------+
| hello   |
| inc1    |
+---------+
2 rows in set (0.00 sec)

还原增量2数据

Preparing 增量2

注意: 最后一次增量preparing 不加--apply-log-only参数

# xtrabackup --prepare  --target-dir=/data/xtrabackup/base --incremental-dir=/data/xtrabackup/inc2
xtrabackup: recognized server arguments: --innodb_checksum_algorithm=crc32 --innodb_log_checksum_algorithm=strict_crc32 --innodb_data_file_path=ibdata1:12M:autoextend --innodb_log_files_in_group=2 --innodb_log_file_size=50331648 --innodb_fast_checksum=0 --innodb_page_size=16384 --innodb_log_block_size=512 --innodb_undo_directory=./ --innodb_undo_tablespaces=0 --server-id=0 --redo-log-version=1 
xtrabackup: recognized client arguments: --prepare=1 --apply-log-only=1 --target-dir=/data/xtrabackup/base --incremental-dir=/data/xtrabackup/inc2 
xtrabackup version 2.4.27 based on MySQL server 5.7.40 Linux (x86_64) (revision id: aae8e82)
incremental backup from 2769346 is enabled.
xtrabackup: cd to /data/xtrabackup/base/
xtrabackup: This target seems to be already prepared with --apply-log-only.
InnoDB: Number of pools: 1
xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(2769704)
xtrabackup: using the following InnoDB configuration for recovery:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup:   innodb_log_group_home_dir = /data/xtrabackup/inc2/
xtrabackup:   innodb_log_files_in_group = 1
xtrabackup:   innodb_log_file_size = 8388608
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 24 for test/messages, old maximum was 0
xtrabackup: page size for /data/xtrabackup/inc2//ibdata1.delta is 16384 bytes space id is 0
Applying /data/xtrabackup/inc2//ibdata1.delta to ./ibdata1...
xtrabackup: page size for /data/xtrabackup/inc2//test/messages.ibd.delta is 16384 bytes space id is 24
.....
230112 18:52:35 [01] Copying /data/xtrabackup/inc2/sys/waits_by_host_by_latency.frm to ./sys/waits_by_host_by_latency.frm
230112 18:52:35 [01]        ...done
230112 18:52:35 [01] Copying /data/xtrabackup/inc2/sys/x@0024ps_digest_95th_percentile_by_avg_us.frm to ./sys/x@0024ps_digest_95th_percentile_by_avg_us.frm
230112 18:52:35 [01]        ...done
230112 18:52:35 [00] Copying /data/xtrabackup/inc2//xtrabackup_binlog_info to ./xtrabackup_binlog_info
230112 18:52:35 [00]        ...done
230112 18:52:35 [00] Copying /data/xtrabackup/inc2//xtrabackup_slave_info to ./xtrabackup_slave_info
230112 18:52:35 [00]        ...done
230112 18:52:35 [00] Copying /data/xtrabackup/inc2//xtrabackup_info to ./xtrabackup_info
230112 18:52:35 [00]        ...done
230112 18:52:35 completed OK!

copy-back base-inc2

# xtrabackup --copy-back --target-dir=/data/xtrabackup/base/ --datadir=/data/xtrabackup/base-copy-back-inc2
xtrabackup: recognized server arguments: --datadir=/data/xtrabackup/base-copy-back-inc2 
xtrabackup: recognized client arguments: --copy-back=1 --target-dir=/data/xtrabackup/base/ 
xtrabackup version 2.4.27 based on MySQL server 5.7.40 Linux (x86_64) (revision id: aae8e82)
230112 19:22:47 [01] Copying ib_logfile0 to /data/xtrabackup/base-copy-back-inc2/ib_logfile0
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ib_logfile1 to /data/xtrabackup/base-copy-back-inc2/ib_logfile1
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ibdata1 to /data/xtrabackup/base-copy-back-inc2/ibdata1
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ./xtrabackup_info to /data/xtrabackup/base-copy-back-inc2/xtrabackup_info
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ./test/messages.ibd to /data/xtrabackup/base-copy-back-inc2/test/messages.ibd
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ./test/messages.frm to /data/xtrabackup/base-copy-back-inc2/test/messages.frm
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ./test/db.opt to /data/xtrabackup/base-copy-back-inc2/test/db.opt
230112 19:22:47 [01]        ...done
230112 19:18:13 [01] Copying ./mysql/user.MYI to /data/xtrabackup/base-copy-back-inc1/mysql/user.MYI
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./mysql/user.frm to /data/xtrabackup/base-copy-back-inc1/mysql/user.frm
230112 19:18:13 [01]        ...done
230112 19:18:13 [01] Copying ./mysql/time_zone_transition_type.ibd to /data/xtrabackup/base-copy-back-inc1/mysql/time_zone_transition_type.ibd
230112 19:18:13 [01]        ...done
...
230112 19:22:47 [01] Copying ./sys/x@0024io_global_by_file_by_bytes.frm to /data/xtrabackup/base-copy-back-inc2/sys/x@0024io_global_by_file_by_bytes.frm
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ./sys/statement_analysis.frm to /data/xtrabackup/base-copy-back-inc2/sys/statement_analysis.frm
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ./sys/waits_by_host_by_latency.frm to /data/xtrabackup/base-copy-back-inc2/sys/waits_by_host_by_latency.frm
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ./sys/x@0024ps_digest_95th_percentile_by_avg_us.frm to /data/xtrabackup/base-copy-back-inc2/sys/x@0024ps_digest_95th_percentile_by_avg_us.frm
230112 19:22:47 [01]        ...done
230112 19:22:47 [01] Copying ./xtrabackup_binlog_pos_innodb to /data/xtrabackup/base-copy-back-inc2/xtrabackup_binlog_pos_innodb
230112 19:22:47 [01]        ...done
230112 19:22:47 completed OK!

停止mysql

# systemctl stop mysqld

同步数据

# rsync -avrP /data/xtrabackup/base-copy-back-inc2/ /data/mysql/data/

修改属组

# chown -R mysql:mysql /data/mysql/data/

重启mysql

# systemctl restart mysqld

查询数据

mysql> select * from messages;
+---------+
| message |
+---------+
| hello   |
| inc1    |
| inc2    |
+---------+
3 rows in set (0.00 sec)

标签:01,--,18,备份,230112,xtrabackup,xtrabackup2.4,增量,data
From: https://www.cnblogs.com/wangguishe/p/17047620.html

相关文章

  • 备份outlook收件人地址列表
       在Outlook中,正常情况下,在收件人地址栏中输入一个字母能以列表显示发送过的收件人地址。但是当重装系统、重建个人帐户配置档时,这些地址列表会丢失,那能否备份outlook......
  • Halo博客上备份到的Markdown文章在本地电脑上Typro中的图片加载不出来
    解决方法方法1.安装Typro的时候一定要右键管理员身份运行.方法2.当图片,和Markdown文章都正常,但是文章中的图片无法加载出来的时候,例如:这个时候,将后面圆括号的内容......
  • sqlserver定时备份
    1.启动代理2.新建维护计划  3.设置计划属性    4.新建备份数据库任务  5.设置备份属性   点击确定,完成......
  • 备份迁移项目
    原因:公司以前做备份的服务器空间满了,有一台2T的对象存储想顶替上来做备份存储服务器。1、先登录原本的备份服务器mysql22、查看传输文件大小[root@mysql2data]#du-h......
  • Linux备份服务
    备份服务一、备份服务概述备份服务:需要使用脚本,打包备份,定时任务通过rsyncd服务,不同主机之间进行数据传输rsyncd特点:rsync是个服务,也是命令使用方便,有多种模式传输......
  • SQLSERVER自动备份数据库
    1.通过操作系统的定时任务执行创建两个文件,auto.bat和auto.sql,使用bat调用sql文件中的代码段auto.bat内容sqlcmd-Slocalhost,2433-Usa-PAa@123456-ddbname-i......
  • 【reacg】【geek】【silence】整合主题备份
    基础设置页面定制CSS/*鼠标指针*/body{cursor:url('https://files-cdn.cnblogs.com/files/miluluyo/cursora.ico'),auto;/*https://blog-static.cnblogs.......
  • 防微杜渐,未雨绸缪,百度网盘(百度云盘)接口API自动化备份上传以及开源发布,基于Golang
    奉行长期主义的开发者都有一个共识:对于服务器来说,数据备份非常重要,因为服务器上的数据通常是无价的,如果丢失了这些数据,可能会导致严重的后果,伴随云时代的发展,备份技术也让......
  • mysql 备份定时任务
    #!/bin/bashrq=`date+%Y-%m-%d-%H`#日期#数据库信息host=127.0.0.1user=rootpassword=xxxdbname=script#放在这个目录path=/usr/local/backups/sqlmysqldump-h......
  • git切换分支备份本地代码(patch)
    场景:自己在master分支开发了一些代码,但现阶段不能向master分支提交代码,需要把修改的部分提交到dev分支;1.拉取目标分支(dev)到master,(mergedevintomaster)2.已经修改的......