How To Backup Nextcloud

https://docs.nextcloud.com/server/11/admin_manual/maintenance/backup.html

https://help.nextcloud.com/t/backup-nextcloud-with-seperate-data-folder-and-the-database/5841/2

good info on rsync:
http://webgnuru.com/linux/rsync_incremental.php

more info on mysql backups:
https://www.liquidweb.com/kb/how-to-back-up-mysql-databases-from-the-command-line/

Restoring Nextcloud from backup:
https://docs.nextcloud.com/server/11/admin_manual/maintenance/restore.html

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:
https://help.nextcloud.com/t/backup-nextcloud-with-seperate-data-folder-and-the-database/5841/7

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

Related

How to manually upgrade Nextcloud

https://docs.nextcloud.com/server/11/admin_manual/maintenance/manual_upgrade.html

and

How To Restore A Nextcloud Backup

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.