MariaDB Docker Container - Setup Daily Backup with Crontab


Every day at 7:00 PM I make a dump of every MariaDB database. This can be done by calling mysqldump 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.

I have the dump placed in a folder that I backup daily. In this case it is a backup folder within the folder of the MariaDB Docker container.

As an example I’m using the Home Assistant database

Crontab

I added the following to the crontab:

0 19 * * * /snap/bin/docker exec mariadb mysqldump --routines --user=USER --password=PASSWORD homeassistant > /home/LINUX-USER/docker/mariadb/backup/homeassistant.sql

Replace the following:

PASSWORD
Replace with your own database password

USER
Replace with your own database user

LINUX-USER
Replace with your own linux user

/snap/bin/docker is the full path of the Docker executable when running Docker with Snap. When not using Snap you can try /usr/bin/docker.


Read other notes

Comments

    No comments found for this note.

    Join the discussion for this note on this ticket. Comments appear on this page instantly.

    Tags


    Notes mentioning this note


    Notes Graph