Fedora 31
Sponsored Link

MariaDB : Backup2019/11/20

 
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

[00] 2019-11-19 09:50:28 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: not set
[00] 2019-11-19 19:50:28 Using server version 10.3.18-MariaDB
mariabackup based on MariaDB server 10.3.18-MariaDB Linux (x86_64)
[00] 2019-11-19 19:50:28 uses posix_fadvise().
[00] 2019-11-19 19:50:28 cd to /var/lib/mysql/
[00] 2019-11-19 19:50:28 open files limit requested 0, set to 1024
[00] 2019-11-19 19:50:28 mariabackup: using the following InnoDB configuration:
.....
.....
[00] 2019-11-19 19:50:30         ...done
[00] 2019-11-19 19:50:30 Redo log (from LSN 1649927 to 1649936) was copied.
[00] 2019-11-19 19:50:30 completed OK!

[root@www ~]#
ll /home/mariadb_backup

total 12332
-rw-r-----. 1 root root    16384 Nov 19 19:50 aria_log.00000001
-rw-r-----. 1 root root       52 Nov 19 19:50 aria_log_control
-rw-r-----. 1 root root      324 Nov 19 19:50 backup-my.cnf
-rw-r-----. 1 root root     1050 Nov 19 19:50 ib_buffer_pool
-rw-r-----. 1 root root 12582912 Nov 19 19:50 ibdata1
-rw-r-----. 1 root root     2560 Nov 19 19:50 ib_logfile0
drwx------. 2 root root     4096 Nov 19 19:50 mysql
drwx------. 2 root root       20 Nov 19 19:50 performance_schema
drwx------. 2 root root       64 Nov 19 19:50 test_database
-rw-r-----. 1 root root       77 Nov 19 19:50 xtrabackup_checkpoints
-rw-r-----. 1 root root      446 Nov 19 19:50 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 211168 Nov 19 19:54 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.18-MariaDB Linux (x86_64)
[00] 2019-11-19 19:56:16 cd to /root/mariadb_backup/
[00] 2019-11-19 19:56:16 This target seems to be not prepared yet.
[00] 2019-11-19 19:56:16 mariabackup: using the following InnoDB configuration for recovery:
[00] 2019-11-19 19:56:16 innodb_data_home_dir = .
[00] 2019-11-19 19:56:16 innodb_data_file_path = ibdata1:12M:autoextend
[00] 2019-11-19 19:56:16 innodb_log_group_home_dir = .
[00] 2019-11-19 19:56:16 InnoDB: Using Linux native AIO
[00] 2019-11-19 19:56:16 Starting InnoDB instance for recovery.
[00] 2019-11-19 19:56:16 mariabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
2019-11-20  9:56:16 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-11-20  9:56:17 0 [Note] InnoDB: Uses event mutexes
2019-11-20  9:56:17 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-11-20  9:56:17 0 [Note] InnoDB: Number of pools: 1
2019-11-20  9:56:17 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-11-20  9:56:17 0 [Note] InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M
2019-11-20  9:56:17 0 [Note] InnoDB: Completed initialization of buffer pool
2019-11-20  9:56:17 0 [Note] InnoDB: page_cleaner coordinator priority: -20
2019-11-20  9:56:17 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=1649927
[00] 2019-11-19 19:56:17 Last binlog file , position 0
[00] 2019-11-19 19:56:17 completed OK!

# run restore

[root@node01 ~]#
mariabackup --copy-back --target-dir /root/mariadb_backup

mariabackup based on MariaDB server 10.3.18-MariaDB Linux (x86_64)
[01] 2019-11-19 19:57:03 Copying ibdata1 to /var/lib/mysql/ibdata1
[01] 2019-11-19 19:57:03         ...done
.....
.....
[01] 2019-11-19 19:57:03 Copying ./xtrabackup_info to /var/lib/mysql/xtrabackup_info
[01] 2019-11-19 19:57:03         ...done
[00] 2019-11-19 19:57:03 completed OK!

[root@node01 ~]#
chown -R mysql. /var/lib/mysql

[root@node01 ~]#
systemctl start mariadb

Matched Content