CentOS Stream 10
Sponsored Link

MariaDB 10.11 : Backup2025/01/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

[00] 2025-01-31 09:10:29 Connecting to MariaDB server host: localhost, user: root, password: not set, port: not set, socket: not set
[00] 2025-01-31 09:10:29 Using server version 10.11.9-MariaDB
mariabackup based on MariaDB server 10.11.9-MariaDB Linux (x86_64)
[00] 2025-01-31 09:10:29 uses posix_fadvise().
[00] 2025-01-31 09:10:29 cd to /var/lib/mysql/
[00] 2025-01-31 09:10:29 Loading encryption plugin
[00] 2025-01-31 09:10:29 open files limit requested 0, set to 1024
[00] 2025-01-31 09:10:29 mariabackup: using the following InnoDB configuration:
[00] 2025-01-31 09:10:29 innodb_data_home_dir =
.....
.....
[00] 2025-01-31 09:10:30 Writing xtrabackup_info
[00] 2025-01-31 09:10:30         ...done
[00] 2025-01-31 09:10:30 Redo log (from LSN 49855 to 49871) was copied.
[00] 2025-01-31 09:10:30 completed OK!

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

total 12744
-rw-r-----. 1 root root   417792 Jan 31 09:10 aria_log.00000001
-rw-r-----. 1 root root       52 Jan 31 09:10 aria_log_control
-rw-r-----. 1 root root      477 Jan 31 09:10 backup-my.cnf
-rw-r-----. 1 root root 12582912 Jan 31 09:10 ibdata1
-rw-r-----. 1 root root    12304 Jan 31 09:10 ib_logfile0
drwx------. 2 root root     4096 Jan 31 09:10 mysql
drwx------. 2 root root       20 Jan 31 09:10 performance_schema
drwx------. 2 root root     8192 Jan 31 09:10 sys
drwx------. 2 root root       64 Jan 31 09:10 test_database
-rw-r-----. 1 root root       97 Jan 31 09:10 xtrabackup_checkpoints
-rw-r-----. 1 root root      432 Jan 31 09:10 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 691738 Jan 31 09:15 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.9-MariaDB Linux (x86_64)
[00] 2025-01-31 09:16:20 cd to /root/mariadb_backup/
[00] 2025-01-31 09:16:20 open files limit requested 0, set to 1024
[00] 2025-01-31 09:16:20 Loading encryption plugin from provider_bzip2=provider_bzip2;provider_lz4=provider_lz4;provider_lzo=provider_lzo;provider_snappy=provider_snappy
[00] 2025-01-31 09:16:20 Loading encryption plugin
[00] 2025-01-31 09:16:20         Encryption plugin parameter :  '--plugin_load=provider_bzip2=provider_bzip2;provider_lz4=provider_lz4;provider_lzo=provider_lzo;provider_snappy=provider_snappy'
[00] 2025-01-31 09:16:20         Encryption plugin parameter :  '--innodb_encrypt_tables=OFF'
[00] 2025-01-31 09:16:20         Encryption plugin parameter :  '--prepare'
[00] 2025-01-31 09:16:20         Encryption plugin parameter :  '--target-dir'
[00] 2025-01-31 09:16:20         Encryption plugin parameter :  '/root/mariadb_backup'
[00] 2025-01-31 09:16:20 This target seems to be not prepared yet.
[00] 2025-01-31 09:16:20 mariabackup: using the following InnoDB configuration for recovery:
[00] 2025-01-31 09:16:20 innodb_data_home_dir = .
[00] 2025-01-31 09:16:20 innodb_data_file_path = ibdata1:12M:autoextend
[00] 2025-01-31 09:16:20 innodb_log_group_home_dir = .
[00] 2025-01-31 09:16:20 InnoDB: Using Linux native AIO
[00] 2025-01-31 09:16:20 Starting InnoDB instance for recovery.
[00] 2025-01-31 09:16:20 mariabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
2025-01-31  9:16:20 0 [Note] InnoDB: Compressed tables use zlib 1.3.0.zlib-ng
2025-01-31  9:16:20 0 [Note] InnoDB: Number of transaction pools: 1
2025-01-31  9:16:20 0 [Note] InnoDB: Using AVX512 instructions
2025-01-31  9:16:20 0 [Note] InnoDB: Using Linux native AIO
2025-01-31  9:16:20 0 [Note] InnoDB: Initializing buffer pool, total size = 100.000MiB, chunk size = 100.000MiB
2025-01-31  9:16:20 0 [Note] InnoDB: Completed initialization of buffer pool
2025-01-31  9:16:20 0 [Note] InnoDB: Buffered log writes (block size=512 bytes)
2025-01-31  9:16:20 0 [Note] InnoDB: End of log at LSN=49871
[00] 2025-01-31 09:16:20 Last binlog file , position 0
recovered pages: 0% 15% 36% 61% 100% (0.0 seconds); tables to flush: 1 0
 (0.0 seconds);
[00] 2025-01-31 09:16:20 completed OK!

# run restore

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

mariabackup based on MariaDB server 10.11.9-MariaDB Linux (x86_64)
[01] 2025-01-31 09:17:01 Copying ./aria_log_control to /var/lib/mysql/aria_log_control
[01] 2025-01-31 09:17:01         ...done
[01] 2025-01-31 09:17:01 Copying ./aria_log.00000001 to /var/lib/mysql/aria_log.00000001
[01] 2025-01-31 09:17:01         ...done
[01] 2025-01-31 09:17:01 Copying ib_logfile0 to /var/lib/mysql/ib_logfile0
[01] 2025-01-31 09:17:01         ...done
[01] 2025-01-31 09:17:01 Copying ibdata1 to /var/lib/mysql/./ibdata1
[01] 2025-01-31 09:17:01         ...done
.....
.....
[01] 2025-01-31 09:17:01 Copying ./xtrabackup_info to /var/lib/mysql/xtrabackup_info
[01] 2025-01-31 09:17:01         ...done
[01] 2025-01-31 09:17:01 Copying ./xtrabackup_binlog_pos_innodb to /var/lib/mysql/xtrabackup_binlog_pos_innodb
[01] 2025-01-31 09:17:01         ...done
[00] 2025-01-31 09:17:01 completed OK!

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

[root@node01 ~]#
systemctl start mariadb

Matched Content