Support intro
Sorry to hear you’re facing problems
help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.
In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:
example
Or for longer, use three backticks above and below the code snippet:
longer
example
here
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
Nextcloud version (eg, 20.0.5): 25.0.2
Operating system and version (eg, Ubuntu 20.04): Debian 11
Apache or nginx version (eg, Apache 2.4.25): 2.4.56-1~deb11u1
PHP version (eg, 7.4): 2:7.4+76
Purpose of installation: personal cloud (only one user)
I am trying to backup my Nextcloud instance and practice restoring it, so I know it will work. In the past, I’ve had database corruption during an upgrade and had to reinstall, so I am trying to get backup and restore sorted before upgrading again.
I’ve followed the backup directions in the manual and have backups of the database dump, the /var/nextcloud root web folder, and the data directory.
QUESTION: How do I practice restoring the backup?
My first thought is to spin up a VM, install Debian 11, install this version of nextcloud from scratch, and restore/copy the files to the locations they should be. Is there an easier way - how would you do it?
Then I would have to restore the database. It looks like this can get quite involved, but the MariaDB docs have a “clumsy way” here Restoring Data from Dump Files - MariaDB Knowledge Base
Is this the way to practice restoring a backup, so I can restore it in case the database gets corrupted again, or I need to recover for another reason?
Thanks,
T.MG.
If you’re curious, my backup script looks like this. I would not recommend copying it as I don’t know best practices, or side effects of what I’m doing.
My backup script
#!/bin/bash
echo "Did you make sure that backup_drive is turned on and mounted on raspi3deb?"
sudo -u www-data php /var/www/nc.example.com/occ maintenance:mode --on
#this automatically echos "Maintenance mode on"
mysqldump --single-transaction --user=nextcloud --password=XXXXXXXXXXXXXXX --lock-tables --databases nextcloud > /var/www/nc.example.com/nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
echo "mysql dump created"
# puts the dump in the web root dir so I don't lose it
restic --cacert=/root/keys/public_key --password-file /root/keys/ncpass -r
# Backup to REST server on raspi3deb
rest:https://user:pass@192.168.1.100:8000/tmg/nc --verbose backup /media/ncdatadir/
restic --cacert=/root/keys/public_key -r rest:https://user:pass@192.168.1.100:8000/tmg/nc --password-file /root/keys/ncpass --verbose backup /var/www/nc.example.com/
sudo -u www-data php /var/www/nc.example.com/occ maintenance:mode --off
echo "Backup Complete. Check output for errors"