How To Restore A Nextcloud Backup

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


$ mysql -h localhost -u root -p nextcloud < /directory/to/nextcloud-sqlbkp.bak



Develop and scale your apps globally with DigitalOcean and/or Vultr – or use shared hosting with no server maintenance required at

Installation & Maintenance

If you would like to get this app installed, maintained or need training, Contact Me to get current rates.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.