Mariabackup backup - gzip compression
Colleagues hello to all.
In today's article, we'll talk about how you can backup a MariaDB database with Mariabackup using compression. Compressing backups in MariaDB is a good practice, as the backup itself can take up a lot of disk space. We will compress our backup using the gzip archiving method. Mariabackup supports streaming data to standard output, and this gives us the fact that we will compress our copy immediately during the backup process.
Related articles:
- Mariabackup Installation on Centos 8
- Mariabackup backup and restore.
- Mariabackup backup - account.
- Mariabackup backup - Store history in database.
- Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe
We'll be testing compression of a 859 megabyte database.
In this example, we will create a normal backup with Mariabackup, but without compression, and look at its size.
$. mariabackup --backup --target-dir=/app/mariabackup/21.07.2022/full --user=mariabackup --password=Qwerty123 --socket=/app/mysql/ data/socket.sock
As you can see, the size of the backup copy is 1.1 gigabytes.
In this example, we will backup the MariaDB database using the gzip compression method. To do this, we need to use an additional parameter that supports data streaming, and it is called --stream=xbstream
$. mariabackup --user=mariabackup --password='Qwerty123' --backup --stream=xbstream --socket=/app/mysql/data/socket.sock | gzip > /app/mariabackup/21.07.2022/full/full.gz
After the backup is complete, we will have a gz archive with our database files.
The size of our backup will be only 250 megabytes.
Now if we want to unpack our backup from the archive we need to use the command:
$. gunzip -c full.gz | mbstream -x
Thank you all, I hope that my article helped you in some way.