https://docs.nextcloud.com/server/stable/admin_manual/maintenance/restore.html
Simply copy your configuration and data folder (or even your whole Nextcloud install and data folder) to your Nextcloud environment. You could use this command:
1. Copy the data directory:
$ sudo rsync -Aax /media/ncbackup/nextcloud-data/ /var/www/data/
To copy the Nextcloud directory (this is optional, you can also just use a new downloaded version of nextcloud):
$ sudo rsync -Aax /media/ncbackup/nextcloud-dirbkp/ /var/www/html/nextcloud/
2. Restore the database
Before restoring a backup you need to make sure to delete all existing database tables.
You can easily do this in phpmyadmin by just dropping all the tables. This is the easiest way. You can also just drop the nextcloud database and create a new one. On the command line you can do this:
mysql -h [server] -u [username] -p[password] -e "DROP DATABASE nextcloud"
mysql -h [server] -u [username] -p[password] -e "CREATE DATABASE nextcloud"
an example looks like this (you will be prompted for your mariadb password):
$ mysql -h localhost -u root -p -e "DROP DATABASE nextcloud"
$ mysql -h localhost -u root -p -e "CREATE DATABASE nextcloud"
Then restore from your backup:
$ mysql -h [server] -u [username] -p[password] [db_name] < nextcloud-sqlbkp.bak
example:
$ mysql -h localhost -u root -p nextcloud < /directory/to/nextcloud-sqlbkp.bak
Done
Hosting
Develop and scale your apps globally with DigitalOcean and/or Vultr – or use shared hosting with no server maintenance required at iMarketHost.com.
Installation & Maintenance
If you would like to get this app installed, maintained or need training, Contact Me to get current rates.
Hello my name is arman. Do you have steps of backup and restore for snap nextcloud? I have 15tB of machine and other machine of 11 tb. I would like to duplicate the whole machine to another machine. What is the best recommendation for backup and restore. thks
I have not installed Nextcloud via snap so I wouldn’t know where the files are located however, you could use something like rsync to duplicate the files from one machine to another. See https://linuxize.com/post/how-to-use-rsync-for-local-and-remote-data-transfer-and-synchronization/ or https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps