Mariabackup backup - gzip compression

  • Last update: Apr 3, 2024
  • Views: 27
  • Author: Admin
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:

  1. Mariabackup Installation on Centos 8
  2. Mariabackup backup and restore.
  3. Mariabackup backup - account.
  4. Mariabackup backup - Store history in database.
  5. Mariabackup error - Error writing file UNKNOWN errno 32 Broken pipe

 

We'll be testing compression of a 859 megabyte database.

mariabackup_compression


 

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

mariabackup_compression

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

mariabackup_compression

 

After the backup is complete, we will have a gz archive with our database files.

mariabackup_compression

 

The size of our backup will be only 250 megabytes.

mariabackup_compression

 

Now if we want to unpack our backup from the archive we need to use the command:

$. gunzip -c full.gz | mbstream -x

mariabackup_compression


 

 

Thank you all, I hope that my article helped you in some way.

 

SIMILAR ARTICLES