MariaDB 10.3 : Backup2020/01/23 |
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. |
# install from SCLo [root@www ~]# yum --enablerepo=centos-sclo-rh -y install rh-mariadb103-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 -p password [00] 2020-01-22 21:43:11 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: not set [00] 2020-01-22 21:43:11 Using server version 10.3.13-MariaDB [00] 2020-01-22 21:43:11 mariabackup based on MariaDB server 10.3.13-MariaDB Linux (x86_64) [00] 2020-01-22 21:43:11 uses posix_fadvise(). [00] 2020-01-22 21:43:11 cd to /var/opt/rh/rh-mariadb103/lib/mysql/ ..... ..... [00] 2020-01-22 21:43:13 ...done [00] 2020-01-22 21:43:13 Writing xtrabackup_info [00] 2020-01-22 21:43:13 ...done [00] 2020-01-22 21:43:13 Redo log (from LSN 1639817 to 1639826) was copied. [00] 2020-01-22 21:43:13 completed OK![root@www ~]# ll /home/mariadb_backup total 12332 -rw-r-----. 1 root root 16384 Jan 22 21:43 aria_log.00000001 -rw-r-----. 1 root root 52 Jan 22 21:43 aria_log_control -rw-r-----. 1 root root 297 Jan 22 21:43 backup-my.cnf -rw-r-----. 1 root root 988 Jan 22 21:43 ib_buffer_pool -rw-r-----. 1 root root 12582912 Jan 22 21:43 ibdata1 -rw-r-----. 1 root root 2560 Jan 22 21:43 ib_logfile0 drwx------. 2 root root 4096 Jan 22 21:43 mysql drwx------. 2 root root 20 Jan 22 21:43 performance_schema -rw-r-----. 1 root root 101 Jan 22 21:43 xtrabackup_checkpoints -rw-r-----. 1 root root 446 Jan 22 21:43 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 rh-mariadb103-mariadb [root@node01 ~]# rm -rf /var/opt/rh/rh-mariadb103/lib/mysql/*
# transferred backup data [root@node01 ~]# ll mariadb_backup.tar.gz -rw-r--r--. 1 root root 213244 Jan 22 21:51 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 [00] 2020-01-22 21:57:52 mariabackup based on MariaDB server 10.3.13-MariaDB Linux (x86_64) [00] 2020-01-22 21:57:52 cd to /root/mariadb_backup/ [00] 2020-01-22 21:57:52 This target seems to be not prepared yet. [00] 2020-01-22 21:57:52 mariabackup: using the following InnoDB configuration for recovery: [00] 2020-01-22 21:57:52 innodb_data_home_dir = . [00] 2020-01-22 21:57:52 innodb_data_file_path = ibdata1:12M:autoextend [00] 2020-01-22 21:57:52 innodb_log_group_home_dir = . [00] 2020-01-22 21:57:52 InnoDB: Using Linux native AIO [00] 2020-01-22 21:57:52 Starting InnoDB instance for recovery. [00] 2020-01-22 21:57:52 mariabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter) 2020-01-22 21:57:52 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2020-01-22 21:57:52 0 [Note] InnoDB: Uses event mutexes 2020-01-22 21:57:52 0 [Note] InnoDB: Compressed tables use zlib 1.2.7 2020-01-22 21:57:52 0 [Note] InnoDB: Number of pools: 1 2020-01-22 21:57:52 0 [Note] InnoDB: Using SSE2 crc32 instructions 2020-01-22 21:57:52 0 [Note] InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M 2020-01-22 21:57:52 0 [Note] InnoDB: Completed initialization of buffer pool 2020-01-22 21:57:52 0 [Note] InnoDB: page_cleaner coordinator priority: -20 2020-01-22 21:57:52 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=1639817 [00] 2020-01-22 21:57:52 Last binlog file , position 0 [00] 2020-01-22 21:57:52 completed OK! # run restore [root@node01 ~]# mariabackup --copy-back --target-dir /root/mariadb_backup [00] 2020-01-22 21:58:27 mariabackup based on MariaDB server 10.3.13-MariaDB Linux (x86_64) [01] 2020-01-22 21:58:27 Copying ibdata1 to /var/opt/rh/rh-mariadb103/lib/mysql/ibdata1 [01] 2020-01-22 21:58:27 ...done ..... ..... [01] 2020-01-22 21:58:28 Copying ./xtrabackup_binlog_pos_innodb to /var/opt/rh/rh-mariadb103/lib/mysql/xtrabackup_binlog_pos_innodb [01] 2020-01-22 21:58:28 ...done [00] 2020-01-22 21:58:28 completed OK![root@node01 ~]# chown -R mysql. /var/opt/rh/rh-mariadb103/lib/mysql [root@node01 ~]# systemctl start rh-mariadb103-mariadb |
Sponsored Link |