How To Backup Nextcloud

good info on rsync:

more info on mysql backups:

Restoring Nextcloud from backup:

To backup an Nextcloud installation there are four main things you need to retain:

  1. The config folder
  2. The data folder
  3. The database
  4. The theme folder

Backup Folders

Simply copy your config, data and theme folders (or even your whole Nextcloud install and data folder) to a place outside of your Nextcloud environment.

1. Copy the data directory (if outside of the nextcloud directory):

$ sudo rsync -Aax /var/www/data/ /media/ncbackup/nextcloud-data_`date +"%Y%m%d"`/

2. Copy the entire Nexcloud install, which includes the required config and theme folders:

$ sudo rsync -Aax /var/www/html/nextcloud/ /media/ncbackup/nextcloud-dirbkp_`date +"%Y%m%d"`/

3. Backup MySQL/MariaDB:

$ mysqldump --single-transaction -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

an example below (the ‘-h' flag is unncessary if the database is on the same server). Also, ‘–lock-tables' is included per the link below:

$ mysqldump --lock-tables -u root -p nextcloud > /media/ncbackup/database/nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

There are some answers to common issues in this link:

If you get a ‘Permission denied' error when trying to backup the database, it is because the current user account you are using does not have the right permission to write to the destination path. Change permissions like this (substituting ‘username'):

$ sudo setfacl -R -m "u:username:rwx" /media/ncbackup

also found at How To Add User Permissions To A Folder in Ubuntu


How to manually upgrade Nextcloud


How To Restore A Nextcloud Backup


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.