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.
# restic snapshots password is correct ID Date Host Tags Directory ---------------------------------------------------------------------- 37f632eb 2018-02-22 11:32:43 hwkb.hostwindsdns.com all_databases.sql b923eed6 2018-02-22 11:45:17 hwkb.hostwindsdns.com database_dump.sql ---------------------------------------------------------------------- 2 snapshots