Creating MySQL Backups with Restic

Restic is capable of reading data from stdin, which can be used for saving the output of a program.

In this article, we will discuss how to use this functionality to take MySQL backups through the use of mysqldump.

As with any interaction with Restic, you must first initialize the repo to perform actions within restic, to do so follow this guide.

The command to pipe a MySQL database dump for an individual database would be as follows –

mysqldump --databases database_name -u database_user -p | restic backup --stdin --stdin-filename database_dump.sql

To do the same thing for ALL databases you can perform a mysqldump of all databases on the server, and pipe the output to Restic as follows –

mysqldump -u database_user -p --all-databases | restic backup --stdin --stdin-filename all_databases.sql

With the above you can see your database back ups through the use of restic snapshots, seen below.





Leave a Reply