How to backup MariaDB databases daily with crontab
Introduction
Every day at 7:00 PM I make a dump of every MariaDB database. This can be done by calling mysqldump, in my case from the MariaDB container. I’m using the crontab to schedule this.
It is important for me to also include the database routines in the backup because I use them with some databases.
The dump is placed in a folder that I backup daily. This worked for me within Ubuntu.
How To
Crontab
As an example I’m using the Home Assistant database.
Add the following to the crontab:
# To edit use your text editor application, for example Nano0 19 * * * /snap/bin/docker exec mariadb mysqldump --routines --user=<db-username> --password=<db-password> homeassistant > /home/<linux-username>/docker/mariadb/backup/homeassistant.sql# IMPORTANT: Please read the instructions belowInstructions:
- Required Replace
<db-username>with your database username - Required Replace
<db-password>with your database password - Required Replace
<linux-username>with your linux username
No comments found for this note.
Join the discussion for this note on Github. Comments appear on this page instantly.