Script for manual database backups on unRAID for when borgbackup doesn't work #5884
DesertCookie
started this conversation in
Wiki
Replies: 2 comments 2 replies
-
Hi, thanks for this guide. However the better approach would have been to follow https://github.com/nextcloud/all-in-one?tab=readme-ov-file#how-to-enable-automatic-updates-without-creating-a-backup-beforehand more closely. Also I wonder what were the exact issues that you were experiencing?
|
Beta Was this translation helpful? Give feedback.
1 reply
-
This is missing overwriting the timeout as the database might take longer than the default of 10s. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background: Borgbackup has been regularly failing on me to the point where I just gave up. I back up my data directory separately anyway, so there was only missing a way to backup the database and configs too.
Compatibility: If you are using unRAID, this script should work without any configuration. Simply copy the code into a file, for example
/mnt/Backup/scripts/backup-ncaio-volumes.sh
and make it executable withchmod +X /mnt/Backup/scripts/backup-ncaio-volumes.sh
. Either run the script manually or add it on a schedule, for example via the Appdata Backup plugin. It will store backups in/mnt/user/Backup/nextcloud-aio/...
and keep them for 30 days.Configurability: There are a few dials you can tweak in the script to make it fit your environment:
VOLUME_PATH
- The path where Docker volumes are mounted on your system.BACKUP_TARGET_PATH
- Where the archives and log is stored.DAYS_TO_KEEP
- Older than X days archives will be deleted.LOG_FILE
- Location and name of the log file.What the script does: The script sets your nextcloud_aio_nextcloud container into maintenance mode, then taking nextcloud_aio_database offline which triggers a database dump in the nextcloud_aio_database_dump volume. This volume, alongside some others is compressed into an archive and stored in the specified backup location. Archives older than the specified amount in days automatically get deleted. Finally, the script restarts the database container, waiting for a few seconds before turning off maintenance mode again. Your config and database backup should be finished within 60-90 seconds.
Example run:
The following run backed up my AIO volumes for a 40-user Nextcloud-AIO instance with about 4TB of data (to give you an idea of the amount of files referenced in the database) with less than a minute in maintenance mode, resulting in a backup archive of about 530MB (down from 900MB uncompressed data).
Restoring from this backup:
It's up to your particular use case to restore from this backup. In the past, I was successful with these steps:
config.php
to make sure nothing breaks).Beta Was this translation helpful? Give feedback.
All reactions