How to restore a Nextcloud backup

With a Nextcloud backup in spot, it is time to study how to restore individuals backups to a new occasion of the on-premises cloud server.

Picture: Jack Wallen

In a current post, I demonstrated how to back up your Nextcloud set up. That process wound up with a backup of unique folders as properly as the expected databases. 

If you’ve got taken treatment of backing up that Nextcloud instance on a frequent foundation, you should have a most the latest backup, on the off-probability a thing ended up to befall your server. Must that be the scenario, you will need to know how to restore claimed backup.

I’m heading to wander you through the system of restoring your backup for Nextcloud.

SEE: Choosing kit: Database administrator (TechRepublic Quality)

What you can require

In purchase to make this do the job, you will will need the adhering to:

  • Your backup file for Nextcloud

  • Your backup database for Nextcloud

  • A new set up of Nextcloud that is at the same release stage as the backed up instance

  • A consumer with sudo privileges

As you can see from the listing earlier mentioned, what we’re heading to do is restore the backup files to a manufacturer new instance of Nextcloud. Mainly because of that, your new instance of Nextcloud will have to be up and jogging.

I am going to think your backup documents are named:

How to migrate the backup documents to Nextcloud

The first factor you need to do is migrate the backup information to the new occasion of Nextcloud. This can be carried out in any way you like. One particular likelihood is by applying the Safe Copy command like so:

scp nextcloudbackup.tgz User@SERVER_IP:/home/person/

Where Consumer is the username on the distant server and SERVER_IP is the IP tackle of the new Nextcloud occasion. 

You will need to do that with both equally the file and databases backup. When people documents are housed in the new area, you are completely ready to proceed.

How to restore data files

The 1st stage is to restore the files backup to the new listing. I will believe your backup file is in .tgz structure. Prior to you transfer the file, unpack it with the command:

sudo tar xvzf nextcloudbackup.tgz

Now we can use rsync to move it like so:

sudo rsync -Aax nextcloudbackup /var/www/html/nextcloud/

Now that the backup files are in place, it really is time to restore the database.

How to restore the database

I’m going to believe the identify of your databases is nextcloud. Just before you can restore the backup, you have to fall the first, which is done with the command:

sudo mysql -h localhost -u Consumer -p -e "Drop Databases nextcloud"

Where by Consumer Is the username with admin legal rights.

Now that the authentic database has been dropped, you require to generate a new databases with the command:

sudo mysql -h localhost -u root -p -e "Produce Database nextcloud"

Up coming, restore the backup to the recently made databases with the command:

sudo mysql -h localhost -u Consumer -p nextcloud < nextclouddb.bak

Where USER is the username with admin rights.

That's all there is to it. You should now be able to log in to the restored instance of Nextcloud and everything is in working order. 

Enjoy the security of having a backup/restore process for your Nextcloud cloud servers.

Also see

Fibo Quantum