[Help] Backing up mariadb with "mariadb-backup"

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • Nextcloud Hub 25 Autumn (32.0.4)
  • Operating system and version (e.g., Ubuntu 24.04):
    • TrueNAS SCALE Community Edition 25.10.1 - Goldeye
  • Web server and version (e.g, Apache 2.4.25):
    • nginx/1.28.0
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • caddy v2.10.2
  • PHP version (e.g, 8.3):
    • PHP 8.4.16
  • Is this the first time you’ve seen this error? (Yes / No):
    • Not applied
  • When did this problem seem to first start?
    • Not applied
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • docker image linuxserver/nextcloud
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

I would to do a periodical backup. As the instance is running on ZFS, I take periodical snaphots of all the files and settings and back them up. The issue is the database. The instance is running on MariaDB. I know the official recommendation is mysqldump/mariadb-dump. However, it takes hours to do a full backup.

I am thinking about an alternative that utilizes mariadb-backup to do an incremental backup and running the following script periodically after a full backup:

#!/bin/bash

export BACKUP_DIR_IN_CONTAINER='/config/backup/2026-01-16'

ts=$(date +'%Y-%m-%d_%H-%M-%S%z')
docker exec nextcloud occ maintenance:mode --on
docker exec nextcloud-mariadb mariadb-backup --backup \
	--databases="nextcloud" \
	--target-dir="${BACKUP_DIR_IN_CONTAINER}/incremental-${ts}/" \
	--incremental-basedir="${BACKUP_DIR_IN_CONTAINER}/base/" \
	--user=ncuser \
	--password="mypassword"
docker exec nextcloud occ maintenance:mode --off

Is it a viable solution? Any other thing I have missed?

Many thanks.

After running it a couple days, I realized that incremental backups are not any quicker than backing up with mysqldump/mariadb-dump but it is significant susceptible to corruptions.

I understand the reasons behind the official approach now.

Due to the extended down time with mysqldump/mariadb-dump , is a master-slave cluster the best compromise in term of redundancy?

For people in the future who may run into this situation:

I discovered there are commands for taking snapshots of the database with external tools. They are called BACKUP STAGE. It is a much quicker solution I have been waiting for.