How to restore a Nextcloud backup

With a Nextcloud backup in put, it can be time to learn how to restore those backups to a new occasion of the on-premises cloud server.

Graphic: Jack Wallen

In a the latest put up, I demonstrated how to back up your Nextcloud installation. That course of action wound up with a backup of certain folders as very well as the necessary databases. 

If you’ve taken care of backing up that Nextcloud occasion on a normal foundation, you need to have a most recent backup, on the off-chance a little something ended up to befall your server. Need to that be the scenario, you will need to know how to restore claimed backup.

I am likely to stroll you through the process of restoring your backup for Nextcloud.

SEE: Hiring package: Database administrator (TechRepublic Quality)

What you will need

In order to make this do the job, you may have to have the adhering to:

  • Your backup file for Nextcloud

  • Your backup database for Nextcloud

  • A new installation of Nextcloud that is at the very same launch degree as the backed up occasion

  • A consumer with sudo privileges

As you can see from the checklist earlier mentioned, what we’re going to do is restore the backup files to a brand new instance of Nextcloud. For the reason that of that, your new instance of Nextcloud should be up and working.

I am going to presume your backup documents are named:

How to migrate the backup files to Nextcloud

The initial factor you need to do is migrate the backup information to the new instance of Nextcloud. This can be completed in any way you like. A person chance is by working with the Safe Copy command like so:

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

Wherever Person is the username on the remote server and SERVER_IP is the IP deal with of the new Nextcloud instance. 

You will require to do that with both equally the file and databases backup. When people documents are housed in the new spot, you might be completely ready to go on.

How to restore documents

The first step is to restore the data files backup to the new directory. I will suppose your backup file is in .tgz format. In advance of you go the file, unpack it with the command:

sudo tar xvzf nextcloudbackup.tgz

Now we can use rsync to go it like so:

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

Now that the backup documents are in put, it is really time to restore the databases.

How to restore the database

I am likely to presume the identify of your database is nextcloud. In advance of you can restore the backup, you have to drop the initial, which is carried out 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 initial databases has been dropped, you will need to build a new databases with the command:

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

Next, restore the backup to the newly created databases with the command:

sudo mysql -h localhost -u Person -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