MariaBackup - how to restore
With MDB 10.3 and newer, innodb format is not anymore compatible with MySQL, thus xtrabackup cannot be used. MariaDB forks xtrabackup to MariaBackup? with similar usage.
We can backup MDB with this example command:
/usr/bin/mariabackup --defaults-file=/etc/my.cnf --backup --target-dir=$DUMP_PATH --user=root --slave-info --throttle=1800 --stream=xbstream | pigz -p2 - > "$DUMP_PATH/$FILENAME"
It stream full binary backup to output using xbstream and, we use parallel gzip to compress this stream.
Restore
Let's assume empty OS with installed MDB >= 10.3
- copy backup file to datadir
- gunzip backup
- unstream backup
- prepare backup with mariabackup
- chown mysql:mysql to the datadir
- restore my.cnf
- remove ib_logfile0
- start MDB
example:
copy RCZ to /data/mysql gunzip RCZ-2018-06-05-10-05-01.xb.gz cat RCZ-2018-06-05-10-05-01.xb | xbstream -x mariabackup --prepare --target-dir=/data/mysql rm /data/mysql/ib_logfile0 bud mame original my.cnf a nebo zkopirujeme z /data/mysql/backup-my.cnf kde je nezbytne minimum pro innodb service mysql start
Pokud z toho delame pokracovani repliky, vezmeme pozici ze zalohy, souboru xtrabackup_slave_info. Co neni ulozene, je pripojeni na master. Pokud mame starou repliku (treba rozbitou) zjistime ze souboru master.info veci jako MASTER_HOST a heslo. Zbytek nam rekne xtrabackup_slave_info.
Priklad:
cat xtrabackup_slave_info: SET GLOBAL gtid_slave_pos = '1-1-3242677459'; CHANGE MASTER TO master_use_gtid = slave_pos cat master.info (puvodni) mariadb-reality-binlog.004329 696915943 192.168.55.51 replicator 76FSIdpACnYh 3306 60 0
Takze z vyse ulozeneho rozjedeme repliku s pokracovanim takto:
MariaDB [(none)]> SET GLOBAL gtid_slave_pos = '1-1-3242677459'; CHANGE MASTER TO master_host="192.168.55.51",master_user="replicator", master_password="76FSIdpACnYh",master_use_gtid=slave_pos; start slave;