Redundant/backup server

I want to set up a 2nd local NAS with Nextcloud to primarily operate as a backup of the first NAS and only needed to be accessed as a Nextcloud instance if the first NAS fails.

Does this make sense…

. rsync all of /var/www/nextcloud to 2nd NAS
. mysqldump entire database and copy/import on 2nd NAS
. copy/modify OS configs necessary to get NC running on 2nd NAS

That should get me a mirrored copy of NAS1 on NAS2 including all user credentials. Then on NAS2 I create a cronjob that calls a script to do a nightly rsync of NAS1 (data) -> NAS2 (data) followed by a scan:files.

a) is this feasible?
b) how would I take care of user/activity database changes?
c) is there a better way?

1 Like

a) It can make sense, it depends what exactly you are looking for. One thing you might want to get familiar with is the data-fingerprint, it makes the clients aware of a restored backup (https://github.com/nextcloud/server/blob/master/config/config.sample.php#L1647-L1660), this way, the clients still keep the files which were not saved since the last backup.

b) You can do incremental backups of your database through binary logs:
https://dev.mysql.com/doc/mysql-backup-excerpt/5.7/en/backup-methods.html

c) Is it more important to have a full backup (with all of the data), or do you prefer a quick restore of the service (and perhaps accept that a few things are missing or will be added later again), you want to have data integrity even if someone hacked into your server a week ago.

  • Against disk failure: a better way could be a RAID system, if a single disk fails, you systems remains available and you can replace the disk within some time.
  • other hardware failure: your strategy looks quite good, perhaps run rsync more often and use the binary logs. Only problem I see: If something is corrupt or breaking, you risk to propagate this broken state to your backup machine.
  • hacked in: already good: you get the files from your backup machine, so the hacker can’t directly access the backup. Problem: you have no history of the data. You could use rsnapshot or similar solutions to do backups over a longer period of time, so you can restore data from some time back (e.g. 1 day, 1 week or 1 month). Also a nice thing, if users delete or break something by accident, you can restore something.

Important:

  • Please test a recovery procedure. Now you have the time to figure out all the details, note them somewhere so when the time comes, you are prepared.
  • Don’t rely on one backup. Keep a second thing somewhere, even if it is a weekly backup on an external disk or something. Ideally this would be in a different location.