# How to backup a MariaDB or MySQL database using MySQLDump

**URL:** <https://forums.spacerex.co/t/how-to-backup-a-mariadb-or-mysql-database-using-mysqldump/380>\
**Category:** HomeLab\
**Created:** [April 12, 2023, 1:49am UTC](https://forums.spacerex.co/t/how-to-backup-a-mariadb-or-mysql-database-using-mysqldump/380 "2023-04-12T01:49:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will](https://forums.spacerex.co/user_avatar/forums.spacerex.co/will/32/14_2.png) [@Will](https://forums.spacerex.co/u/Will)\
**Post date:** [April 12, 2023, 1:49am UTC](https://forums.spacerex.co/t/how-to-backup-a-mariadb-or-mysql-database-using-mysqldump/380/1 "2023-04-12T01:49:03Z")

</div>

After my video last week on what I am self hosting:

[![](https://forums.spacerex.co/uploads/default/original/1X/bebc9fab6be932f78268544a6c965d7c2eb34f10.jpeg "What is on my Home Servers? - Virtualization, Databases, Services & More") ](https://www.youtube.com/watch?v=lqormlDJLz0)

I had a few people ask about my database backup script. I am going to do an upcoming video on it, but because I need to add the code somewhere, so I made a write up on [www.spacerex.co](http://www.spacerex.co)! Write up here:

[https://www.spacerex.co/how-to-automatically-backup-a-mysql-or-mariadb-server-with-mysqldump/](https://www.spacerex.co/how-to-automatically-backup-a-mysql-or-mariadb-server-with-mysqldump/)

Let me know what you think & if this still needs a video!

---

<div class="post-metadata">

**Author:** ![Steve](https://forums.spacerex.co/user_avatar/forums.spacerex.co/steve/32/1271_2.png) [@Steve](https://forums.spacerex.co/u/Steve)\
**Post date:** [July 16, 2023, 3:41am UTC](https://forums.spacerex.co/t/how-to-backup-a-mariadb-or-mysql-database-using-mysqldump/380/2 "2023-07-16T03:41:20Z")

</div>

Hi Will,

Presumably you use Mariaa.db as a general database for many applications.

Could you give:

- a run down of how you do this

- what applications you are targeting to the DB

- how you configure the applications to use the DB

Using a single DB definitely interests me - just not sure how to do it.

Also - where do you host the DB? Synology?

Do you have any pointers to tutorials?

Cheers

Steve

---

<div class="post-metadata">

**Author:** ![h3li0](https://forums.spacerex.co/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@h3li0](https://forums.spacerex.co/u/h3li0)\
**Post date:** [October 11, 2023, 5:17pm UTC](https://forums.spacerex.co/t/how-to-backup-a-mariadb-or-mysql-database-using-mysqldump/380/3 "2023-10-11T17:17:23Z")

</div>

also interested in this topic - I’m just starting into the NAS world having received my DS923+ a couple of days ago.

I definitely want to use a single db for all the applications that I’m considering running with docker, so definitely a tutorial around this would be greatly appreciated \* winking at @Will \* 😃

---

<div class="post-metadata">

**Author:** ![raphh](https://forums.spacerex.co/letter_avatar_proxy/v4/letter/r/a4c791/32.png) [@raphh](https://forums.spacerex.co/u/raphh)\
**Post date:** [June 7, 2024, 8:18pm UTC](https://forums.spacerex.co/t/how-to-backup-a-mariadb-or-mysql-database-using-mysqldump/380/4 "2024-06-07T20:18:47Z")

</div>

Same as you @Steve and @h3li0, also interested in this topic after I saw your video and saw database was the first topic you mentioned.

I think a full video on this topic would be very useful for a lot of us 🙏

Maybe you guys find any info on this topic since then?

---

<div class="post-metadata">

**Author:** ![Steve](https://forums.spacerex.co/user_avatar/forums.spacerex.co/steve/32/1271_2.png) [@Steve](https://forums.spacerex.co/u/Steve)\
**Post date:** [June 12, 2024, 7:18am UTC](https://forums.spacerex.co/t/how-to-backup-a-mariadb-or-mysql-database-using-mysqldump/380/5 "2024-06-12T07:18:20Z")

</div>

Some updates on what Will has posted.

**Step 1 - Creating the Backup User**

CREATE USER ‘backupuser’@‘localhost’ IDENTIFIED BY ‘password’;

GRANT LOCK TABLES, SELECT, SHOW VIEW, PROCESS ON _._ TO ‘backupuser’@‘localhost’;

FLUSH PRIVILEGES;

EXIT;

There are 2 ways to backup MariaDB:

> **[Backup and Restore Overview | MariaDB Documentation](https://mariadb.com/docs/server/server-usage/backup-and-restore/backup-and-restore-overview)**

- 
  1. Using mariadb-dump & mysqldump – The mariadb-dump utility is the newer name for mysqldump, though you can still run it using either name.

- 
  1. Using mariadb-backup

This guide uses MySQLDump - [Making Backups with mariadb-dump](https://mariadb.com/kb/en/making-backups-with-mariadb-dump/)

Here are some other links on MariaDB backup using different methods:

- · [Comprehensive Guide: Backing Up and Recovering Data in MariaDB](https://travishorn.com/comprehensive-guide-backing-up-and-recovering-data-in-mariadb)
- · [MariaDB Full Backup and Restore with Mariabackup](https://minervadb.com/index.php/mariadb-full-backup-and-restore-with-mariabackup/)
- · [mysqldump – Create a Separate User to Back Up MariaDB Databases](https://www.linuxbabe.com/mariadb/mysqldump-backup-mariadb-databases)

Cheers

---

<div class="post-metadata">

**Author:** ![Scampi\_ml](https://forums.spacerex.co/user_avatar/forums.spacerex.co/scampi_ml/32/1183_2.png) [@Scampi\_ml](https://forums.spacerex.co/u/Scampi_ml)\
**Post date:** [January 25, 2025, 9:24am UTC](https://forums.spacerex.co/t/how-to-backup-a-mariadb-or-mysql-database-using-mysqldump/380/6 "2025-01-25T09:24:39Z")

</div>

Sorry for grave digging, but i use this

> **[GitHub - Scampi-ml/backup\_sql\_databases: Script dumps all MySQL (or MariaDB) databases to...](https://github.com/Scampi-ml/backup_sql_databases)**
>
> Script dumps all MySQL (or MariaDB) databases to separate SQL files (compressed to .sql.gz) named with timestamp. It also removes old backups (older than specified amount of days).

It works perfectly fine on DSM
