Skip to content

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 Nano
0 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 below
Instructions:
  • Required Replace <db-username> with your database username
  • Required Replace <db-password> with your database password
  • Required Replace <linux-username> with your linux username

Comments

    No comments found for this note.

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

    Copyright 2021- Fiction Becomes Fact