59 cards
Posted over 1 year ago. Visible to the public.

Stream and restore a mariabackup to another host with netcat

If you have a very large datadir in MariaDB and you want to transfer this datadir to another host (e.g. for replication) you may want to avoid storing it locally and copying it between the hosts.

You can stream the backup directly via netcat.

Transfering the stream data

  1. on the destination host
$ mkdir mariabackup $ cd mariabackup $ nc -l 9999 | cat - | mbstream -x
  1. on the source host
mariabackup --backup --stream=xbstream | nc destination-host 9999

restoring the backup

After the streaming of the backup is complete, on the destination host run:

  1. systemctl stop mariadb

  2. rm -r /var/lib/mysql/*

  3. To setup replication afterswards, get the output of:

    cat xtrabackup_binlog_info
  4. Prepare and restore the backup:

    $ cd .. $ mariabackup --prepare --target-dir ./mariabackup $ mariabackup --move-back --target-dir ./mariabackup
  5. chown -R mysql:mysql /var/lib/mysql/

  6. systemctl start mariadb

Owner of this card:

Claus-Theodor Riegg
Last edit:
over 1 year ago
by Claus-Theodor Riegg
This website uses short-lived cookies to improve usability.
Accept or learn more