Hostwinds Tutorials

Search results for:

Creating MySQL Backups with Restic

Tags Cloud servers,  Hostwinds,  dedicated hosting 

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.

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 backups through restic snapshots, seen below.

# restic snapshots
password is correct
ID Date Host Tags Directory
37f632eb 2018-02-22 11:32:43 all_databases.sql
b923eed6 2018-02-22 11:45:17 database_dump.sql
2 snapshots

Written by Hostwinds Team  /  June 5, 2021

Need help? Chat now!