MariaDB 10.5 : Backup2023/03/03 |
For Backup and Restore MariaDB Data, it's possible to run with [mariabackup].
|
|
[1] | Generally [mariabackup] tool is installed with MariaDB Server for dependency, but if it has not been installed, Install it first. |
[root@www ~]# dnf -y install mariadb-backup
|
[2] | Run Backup. For example, get backup under [/home/mariadb_backup]. |
[root@www ~]# mkdir /home/mariadb_backup [root@www ~]# mariabackup --backup --target-dir /home/mariadb_backup -u root [00] 2022-03-17 13:56:11 Connecting to MySQL server host: localhost, user: root, password: not set, port: not set, socket: not set [00] 2022-03-17 13:56:11 Using server version 10.5.13-MariaDB mariabackup based on MariaDB server 10.5.13-MariaDB Linux (x86_64) [00] 2022-03-17 13:56:11 uses posix_fadvise(). [00] 2022-03-17 13:56:11 cd to /var/lib/mysql/ [00] 2022-03-17 13:56:11 open files limit requested 0, set to 1024 [00] 2022-03-17 13:56:11 mariabackup: using the following InnoDB configuration: [00] 2022-03-17 13:56:11 innodb_data_home_dir = ..... ..... [00] 2022-03-17 13:56:13 ...done [00] 2022-03-17 13:56:13 Writing xtrabackup_info [00] 2022-03-17 13:56:13 ...done [00] 2022-03-17 13:56:13 Redo log (from LSN 47586 to 47598) was copied. [00] 2022-03-17 13:56:13 completed OK![root@www ~]# ll /home/mariadb_backup total 12340 -rw-r-----. 1 root root 24576 Mar 17 13:56 aria_log.00000001 -rw-r-----. 1 root root 52 Mar 17 13:56 aria_log_control -rw-r-----. 1 root root 297 Mar 17 13:56 backup-my.cnf -rw-r-----. 1 root root 992 Mar 17 13:56 ib_buffer_pool -rw-r-----. 1 root root 12582912 Mar 17 13:56 ibdata1 -rw-r-----. 1 root root 2560 Mar 17 13:56 ib_logfile0 drwx------. 2 root root 4096 Mar 17 13:56 mysql drwx------. 2 root root 20 Mar 17 13:56 performance_schema drwx------. 2 root root 64 Mar 17 13:56 test_database -rw-r-----. 1 root root 73 Mar 17 13:56 xtrabackup_checkpoints -rw-r-----. 1 root root 432 Mar 17 13:56 xtrabackup_info |
[3] | For restoring data from backup on another host, run like follows. Before restoring, transfer backup data to the target host with [rsync] or [scp] and so on. |
# stop MariaDB and remove existing data [root@node01 ~]# systemctl stop mariadb [root@node01 ~]# rm -rf /var/lib/mysql/*
# transfered backup data [root@node01 ~]# ll mariadb_backup.tar.gz -rw-r--r--. 1 root root 408867 Mar 17 13:58 mariadb_backup.tar.gz [root@node01 ~]# tar zxvf mariadb_backup.tar.gz # run prepare task before restore task (OK if [completed OK]) [root@node01 ~]# mariabackup --prepare --target-dir /root/mariadb_backup mariabackup based on MariaDB server 10.5.13-MariaDB Linux (x86_64) [00] 2022-03-17 14:04:21 cd to /root/mariadb_backup/ [00] 2022-03-17 14:04:21 open files limit requested 0, set to 1024 [00] 2022-03-17 14:04:21 This target seems to be not prepared yet. [00] 2022-03-17 14:04:21 mariabackup: using the following InnoDB configuration for recovery: [00] 2022-03-17 14:04:21 innodb_data_home_dir = . [00] 2022-03-17 14:04:21 innodb_data_file_path = ibdata1:12M:autoextend [00] 2022-03-17 14:04:21 innodb_log_group_home_dir = . [00] 2022-03-17 14:04:21 InnoDB: Using Linux native AIO [00] 2022-03-17 14:04:21 Starting InnoDB instance for recovery. [00] 2022-03-17 14:04:21 mariabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter) 2022-03-17 14:04:21 0 [Note] InnoDB: Uses event mutexes 2022-03-17 14:04:21 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2022-03-17 14:04:21 0 [Note] InnoDB: Number of pools: 1 2022-03-17 14:04:21 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions 2022-03-17 14:04:21 0 [Note] InnoDB: Using Linux native AIO 2022-03-17 14:04:21 0 [Note] InnoDB: Initializing buffer pool, total size = 104857600, chunk size = 104857600 2022-03-17 14:04:21 0 [Note] InnoDB: Completed initialization of buffer pool 2022-03-17 14:04:21 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=47586,47586 [00] 2022-03-17 14:04:22 Last binlog file , position 0 [00] 2022-03-17 14:04:22 completed OK! # run restore [root@node01 ~]# mariabackup --copy-back --target-dir /root/mariadb_backup mariabackup based on MariaDB server 10.5.13-MariaDB Linux (x86_64) [01] 2022-03-17 14:04:35 Copying ibdata1 to /var/lib/mysql/ibdata1 [01] 2022-03-17 14:04:35 ...done [01] 2022-03-17 14:04:35 Copying ./mysql/innodb_table_stats.ibd to /var/lib/mysql/mysql/innodb_table_stats.ibd [01] 2022-03-17 14:04:35 ...done [01] 2022-03-17 14:04:35 Copying ./mysql/innodb_index_stats.ibd to /var/lib/mysql/mysql/innodb_index_stats.ibd [01] 2022-03-17 14:04:35 ...done [01] 2022-03-17 14:04:35 Copying ./mysql/transaction_registry.ibd to /var/lib/mysql/mysql/transaction_registry.ibd [01] 2022-03-17 14:04:35 ...done ..... ..... [01] 2022-03-17 14:04:35 ...done [01] 2022-03-17 14:04:35 Copying ./ib_buffer_pool to /var/lib/mysql/ib_buffer_pool [01] 2022-03-17 14:04:35 ...done [01] 2022-03-17 14:04:35 Copying ./xtrabackup_info to /var/lib/mysql/xtrabackup_info [01] 2022-03-17 14:04:35 ...done [00] 2022-03-17 14:04:35 completed OK![root@node01 ~]# chown -R mysql. /var/lib/mysql [root@node01 ~]# systemctl start mariadb |
Sponsored Link |
|