Automate dietpi-backup

/mnt/dietpi_userdata is only included when it’s on the same drive. If you moved it to an external drive, it’s not included and you need to create a separate script for that. You could use dietpi-sync and a similar approach for multiple backup rotation.

But for the database, a raw file backup is not what I would do, as it can only be reliably restored to the exact same MariaDB version then, theoretically a newer one as well, but I would not count on that. Instead do a regular database SQL dump, so that you can import it on any SQL database server and even browse/edit the SQL commands, if required.

I use this as daily cron job:

mysqldump --log-error=/var/log/nextcloud-db-backup.log nextcloud > /mnt/sda/ncdata/database-backups/$(date +%Y-%m-%d_%T).sql

Reminds me that I need to add an automated removal of old backups, currently it’s growing until I manually clean them up :rofl:.

This is then mirrored again to a second backup drive, together with the Nextcloud data, to protect against data loss through drive crash. I know, a RAID tower would be better :wink:.