MariaDB 10.3 : Backup2019/10/31 |
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 -p password 191030 19:39:26 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: not set Using server version 10.3.11-MariaDB mariabackup based on MariaDB server 10.3.11-MariaDB Linux (x86_64) mariabackup: uses posix_fadvise(). mariabackup: cd to /var/lib/mysql/ mariabackup: open files limit requested 0, set to 1024 mariabackup: using the following InnoDB configuration: mariabackup: innodb_data_home_dir = mariabackup: innodb_data_file_path = ibdata1:12M:autoextend mariabackup: innodb_log_group_home_dir = ./ 2019-10-30 19:39:26 0x7f9cd4f3b900 InnoDB: Using Linux native AIO 2019-10-30 19:39:26 0 [Note] InnoDB: Number of pools: 1 ..... ..... 191030 19:39:28 [00] ...done mariabackup: Redo log (from LSN 1636111 to 1636120) was copied. 191030 19:39:28 completed OK![root@www ~]# ll /home/mariadb_backup total 12332 -rw-r-----. 1 root root 16384 Oct 30 19:39 aria_log.00000001 -rw-r-----. 1 root root 52 Oct 30 19:39 aria_log_control -rw-r-----. 1 root root 297 Oct 30 19:39 backup-my.cnf -rw-r-----. 1 root root 972 Oct 30 19:39 ib_buffer_pool -rw-r-----. 1 root root 12582912 Oct 30 19:39 ibdata1 -rw-r-----. 1 root root 2560 Oct 30 19:39 ib_logfile0 drwx------. 2 root root 4096 Oct 30 19:39 mysql drwx------. 2 root root 20 Oct 30 19:39 performance_schema drwx------. 2 root root 64 Oct 30 19:39 test_database -rw-r-----. 1 root root 101 Oct 30 19:39 xtrabackup_checkpoints -rw-r-----. 1 root root 446 Oct 30 19:39 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 208914 Oct 30 19:39 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.3.11-MariaDB Linux (x86_64) mariabackup: cd to /root/mariadb_backup/ mariabackup: This target seems to be not prepared yet. mariabackup: using the following InnoDB configuration for recovery: mariabackup: innodb_data_home_dir = . mariabackup: innodb_data_file_path = ibdata1:12M:autoextend mariabackup: innodb_log_group_home_dir = . 2019-10-30 20:03:55 0x7f1537001900 InnoDB: Using Linux native AIO mariabackup: Starting InnoDB instance for recovery. mariabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter) 2019-10-30 20:03:55 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2019-10-30 20:03:55 0 [Note] InnoDB: Uses event mutexes 2019-10-30 20:03:55 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2019-10-30 20:03:55 0 [Note] InnoDB: Number of pools: 1 2019-10-30 20:03:55 0 [Note] InnoDB: Using SSE2 crc32 instructions 2019-10-30 20:03:55 0 [Note] InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M 2019-10-30 20:03:55 0 [Note] InnoDB: Completed initialization of buffer pool 2019-10-30 20:03:55 0 [Note] InnoDB: page_cleaner coordinator priority: -20 2019-10-30 20:03:55 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=1636111 Last binlog file , position 0 191030 20:03:56 completed OK! # run restore [root@node01 ~]# mariabackup --copy-back --target-dir /root/mariadb_backup mariabackup based on MariaDB server 10.3.11-MariaDB Linux (x86_64) 191031 10:04:51 [01] Copying ibdata1 to /var/lib/mysql/ibdata1 191031 10:04:51 [01] ...done ..... ..... 191031 10:04:51 [01] Copying ./xtrabackup_binlog_pos_innodb to /var/lib/mysql/xtrabackup_binlog_pos_innodb 191031 10:04:51 [01] ...done 191031 10:04:51 completed OK![root@node01 ~]# chown -R mysql. /var/lib/mysql [root@node01 ~]# systemctl start mariadb |
Sponsored Link |