MariaDB 10.11 : Backup2023/04/28 |
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] 2023-04-28 07:42:48 Executing BACKUP STAGE END [00] 2023-04-28 07:42:48 All tables unlocked [00] 2023-04-28 07:42:48 Backup created in directory '/home/mariadb_backup/' [00] 2023-04-28 07:42:48 Writing backup-my.cnf [00] 2023-04-28 07:42:48 ...done [00] 2023-04-28 07:42:48 Writing xtrabackup_info [00] 2023-04-28 07:42:48 ...done [00] 2023-04-28 07:42:48 Redo log (from LSN 49163 to 49179) was copied. [00] 2023-04-28 07:42:48 completed OK!root@www:~# ll /home/mariadb_backup total 12760 drwxr-xr-x 6 root root 4096 Apr 28 07:42 ./ drwxr-xr-x 5 root root 4096 Apr 28 07:42 ../ -rw-r----- 1 root root 417792 Apr 28 07:42 aria_log.00000001 -rw-r----- 1 root root 52 Apr 28 07:42 aria_log_control -rw-r----- 1 root root 475 Apr 28 07:42 backup-my.cnf -rw-r----- 1 root root 12304 Apr 28 07:42 ib_logfile0 -rw-r----- 1 root root 12582912 Apr 28 07:42 ibdata1 drwx------ 2 root root 4096 Apr 28 07:42 mysql/ drwx------ 2 root root 4096 Apr 28 07:42 performance_schema/ drwx------ 2 root root 12288 Apr 28 07:42 sys/ drwx------ 2 root root 4096 Apr 28 07:42 test_database/ -rw-r----- 1 root root 73 Apr 28 07:42 xtrabackup_checkpoints -rw-r----- 1 root root 434 Apr 28 07:42 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 706509 Apr 28 07:48 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.2-MariaDB debian-linux-gnu (x86_64) [00] 2023-04-28 07:49:44 cd to /root/mariadb_backup/ [00] 2023-04-28 07:49:44 open files limit requested 0, set to 1024 [00] 2023-04-28 07:49:44 Loading plugins from provider_bzip2=provider_bzip2;provider_lz4=provider_lz4;provider_lzma=provider_lzma;provider_lzo=provider_lzo;provider_snappy=provider_snappy [00] 2023-04-28 07:49:44 Loading plugins [00] 2023-04-28 07:49:44 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] 2023-04-28 07:49:44 Plugin parameter : '--prepare' [00] 2023-04-28 07:49:44 Plugin parameter : '--target-dir' [00] 2023-04-28 07:49:44 Plugin parameter : '/root/mariadb_backup' [00] 2023-04-28 07:49:44 This target seems to be not prepared yet. [00] 2023-04-28 07:49:44 mariabackup: using the following InnoDB configuration for recovery: [00] 2023-04-28 07:49:44 innodb_data_home_dir = . [00] 2023-04-28 07:49:44 innodb_data_file_path = ibdata1:12M:autoextend [00] 2023-04-28 07:49:44 innodb_log_group_home_dir = . [00] 2023-04-28 07:49:44 InnoDB: Using liburing [00] 2023-04-28 07:49:44 Starting InnoDB instance for recovery. [00] 2023-04-28 07:49:44 mariabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter) 2023-04-28 7:49:44 0 [Note] InnoDB: Compressed tables use zlib 1.2.13 2023-04-28 7:49:44 0 [Note] InnoDB: Number of transaction pools: 1 2023-04-28 7:49:44 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions 2023-04-28 7:49:44 0 [Note] InnoDB: Using liburing 2023-04-28 7:49:44 0 [Note] InnoDB: Initializing buffer pool, total size = 100.000MiB, chunk size = 100.000MiB 2023-04-28 7:49:44 0 [Note] InnoDB: Completed initialization of buffer pool 2023-04-28 7:49:44 0 [Note] InnoDB: Buffered log writes (block size=512 bytes) [00] 2023-04-28 07:49:44 Last binlog file , position 0 [00] 2023-04-28 07:49:44 completed OK! # run restore root@node01:~# mariabackup --copy-back --target-dir /root/mariadb_backup ..... ..... [01] 2023-04-28 07:50:09 Copying ./mysql/proc.MAI to /var/lib/mysql/mysql/proc.MAI [01] 2023-04-28 07:50:09 ...done [01] 2023-04-28 07:50:09 Copying ./mysql/time_zone_transition_type.frm to /var/lib/mysql/mysql/time_zone_transition_type.frm [01] 2023-04-28 07:50:09 ...done [01] 2023-04-28 07:50:09 Copying ./mysql/tables_priv.MAI to /var/lib/mysql/mysql/tables_priv.MAI [01] 2023-04-28 07:50:09 ...done [01] 2023-04-28 07:50:09 Copying ./aria_log_control to /var/lib/mysql/aria_log_control [01] 2023-04-28 07:50:09 ...done [01] 2023-04-28 07:50:09 Copying ./performance_schema/db.opt to /var/lib/mysql/performance_schema/db.opt [01] 2023-04-28 07:50:09 ...done [00] 2023-04-28 07:50:09 completed OK!root@node01:~# chown -R mysql:mysql /var/lib/mysql root@node01:~# systemctl start mariadb |
Sponsored Link |