MariaDB 10.11 : Backup2024/05/17 |
For Backup and Restore MariaDB Data, it's possible to run with [mariabackup].
|
|
[1] | Install Backup tool. |
root@www:~# apt -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] 2024-05-17 00:47:14 Executing BACKUP STAGE END [00] 2024-05-17 00:47:14 All tables unlocked [00] 2024-05-17 00:47:14 Backup created in directory '/home/mariadb_backup/' [00] 2024-05-17 00:47:14 Writing backup-my.cnf [00] 2024-05-17 00:47:14 ...done [00] 2024-05-17 00:47:14 Writing xtrabackup_info [00] 2024-05-17 00:47:14 ...done [00] 2024-05-17 00:47:14 Redo log (from LSN 49855 to 49871) was copied. [00] 2024-05-17 00:47:14 completed OK!root@www:~# ll /home/mariadb_backup total 12760 drwxr-xr-x 6 root root 4096 May 17 00:47 ./ drwxr-xr-x 4 root root 4096 May 17 00:47 ../ -rw-r----- 1 root root 417792 May 17 00:47 aria_log.00000001 -rw-r----- 1 root root 52 May 17 00:47 aria_log_control -rw-r----- 1 root root 475 May 17 00:47 backup-my.cnf -rw-r----- 1 root root 12304 May 17 00:47 ib_logfile0 -rw-r----- 1 root root 12582912 May 17 00:47 ibdata1 drwx------ 2 root root 4096 May 17 00:47 mysql/ drwx------ 2 root root 4096 May 17 00:47 performance_schema/ drwx------ 2 root root 12288 May 17 00:47 sys/ drwx------ 2 root root 4096 May 17 00:47 test_database/ -rw-r----- 1 root root 97 May 17 00:47 xtrabackup_checkpoints -rw-r----- 1 root root 441 May 17 00:47 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/*
# transferred backup data root@node01:~# ll mariadb_backup.tar.gz -rw-r--r-- 1 root root 700203 May 17 00:49 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.11.7-MariaDB debian-linux-gnu (x86_64) [00] 2024-05-17 00:51:42 cd to /root/mariadb_backup/ [00] 2024-05-17 00:51:42 open files limit requested 0, set to 1024 [00] 2024-05-17 00:51:42 Loading plugins from provider_bzip2=provider_bzip2;provider_lz4=provider_lz4;provider_lzma=provider_lzma;provider_lzo=provider_lzo;provider_snappy=provider_snappy [00] 2024-05-17 00:51:42 Loading plugins [00] 2024-05-17 00:51:42 Plugin parameter : '--plugin_load=provider_bzip2=provider_bzip2;provider_lz4=provider_lz4;provider_lzma=provider_lzma;provider_lzo=provider_lzo;provider_snappy=provider_snappy' [00] 2024-05-17 00:51:42 Plugin parameter : '--prepare' [00] 2024-05-17 00:51:42 Plugin parameter : '--target-dir' [00] 2024-05-17 00:51:42 Plugin parameter : '/root/mariadb_backup' [00] 2024-05-17 00:51:42 This target seems to be not prepared yet. [00] 2024-05-17 00:51:42 mariabackup: using the following InnoDB configuration for recovery: [00] 2024-05-17 00:51:42 innodb_data_home_dir = . [00] 2024-05-17 00:51:42 innodb_data_file_path = ibdata1:12M:autoextend [00] 2024-05-17 00:51:42 innodb_log_group_home_dir = . [00] 2024-05-17 00:51:42 InnoDB: Using liburing [00] 2024-05-17 00:51:42 Starting InnoDB instance for recovery. [00] 2024-05-17 00:51:42 mariabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter) 2024-05-17 0:51:42 0 [Note] InnoDB: Compressed tables use zlib 1.3 2024-05-17 0:51:42 0 [Note] InnoDB: Number of transaction pools: 1 2024-05-17 0:51:42 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions 2024-05-17 0:51:42 0 [Note] InnoDB: Using liburing 2024-05-17 0:51:42 0 [Note] InnoDB: Initializing buffer pool, total size = 100.000MiB, chunk size = 100.000MiB 2024-05-17 0:51:42 0 [Note] InnoDB: Completed initialization of buffer pool 2024-05-17 0:51:42 0 [Note] InnoDB: Buffered log writes (block size=512 bytes) 2024-05-17 0:51:42 0 [Note] InnoDB: End of log at LSN=49871 [00] 2024-05-17 00:51:42 Last binlog file , position 0 [00] 2024-05-17 00:51:42 completed OK! # run restore root@node01:~# mariabackup --copy-back --target-dir /root/mariadb_backup ..... ..... [01] 2024-05-17 00:52:30 Copying ./mysql/innodb_index_stats.ibd to /var/lib/mysql/mysql/innodb_index_stats.ibd [01] 2024-05-17 00:52:30 ...done [01] 2024-05-17 00:52:30 Copying ./mysql/innodb_index_stats.frm to /var/lib/mysql/mysql/innodb_index_stats.frm [01] 2024-05-17 00:52:30 ...done [01] 2024-05-17 00:52:30 Copying ./mysql/proc.MAI to /var/lib/mysql/mysql/proc.MAI [01] 2024-05-17 00:52:30 ...done [01] 2024-05-17 00:52:30 Copying ./mysql/table_stats.frm to /var/lib/mysql/mysql/table_stats.frm [01] 2024-05-17 00:52:30 ...done [00] 2024-05-17 00:52:30 completed OK!root@node01:~# chown -R mysql:mysql /var/lib/mysql root@node01:~# systemctl start mariadb |
Sponsored Link |