mirror full nextcloud on 2 servers

Hello
my question is as follows, is it possible to mirror nextcloud on 2 servers?
I mean in case one is damaged at a critical level, continue to work with it without losing data.
the idea would be to have 2 fully functional nextcloud servers that are self-synchronizing with each other.
Thank you

There is no easy solution for this yet. Please do a search next time since this has been asked many times. Thank you!

1 Like

That can be easily done using VMware FT (fault tolerance), but it won’t be cheap…

Sure, but it is working with virtual machines and in this case the machine is physical

If you can’t afford downtime - what FT is all about! - you have to pay.
And in this case I’d not rely on built-in tools to achieve this (even IF it had any)…

If you need just high availability or something, do backups… Hourly!..
Veeam does a good job with that…

Does it need automatic failover?

MariaDB (formerly known as MySQL) can be set up with database replication to automatically keep the databases on two servers synchronized.

Then you have options for data replication;

  1. rsync on cron at whatever frequency you wish,
  2. custom script/plugin monitoring the “master” nextcloud instance for data changes, and immediately replicating them to the backup instance.
  3. fancy shmancy network filesystem replication.

I don’t generally recommend auto-failover, because if the master server goes offline just briefly, you would have to sync back from the backup server, and this can get complicated, but, you could possibly set it up so that it disables the master server if it goes off and back on-line, so that the restoration has to be performed manually.

Failover can be handled at a DNS or proxy level (haproxy?)

Actually there IS a solution for this, but it’s not as simple as clicking a box in an on-screen gadget to create a duplicate server backup.

I run Nextcloud in an LXC (LXD) container (Ubuntu linux specifically, with LXD version 4.x). With such, it is possible to create a full backup with one simple command using lxc:

lxc copy Nextcloud server2:Nextcloud-bak --refresh

Believe it or not, this creates an entire working copy of a Nextcloud instance in the container, which in my deliberate case includes apache2, mysql and all Nextcloud configs. It can also include the Nextcould data directory if you want (but that makes the container very large). server2: can be on the same lan or on the other side of thr world. A --refresh option makes updates very fast and practical for even internet-based server connections (where bandwidth is usually low). The initial copy might take a few minutes, but the --refresh update is typically seconds for me (home user), but even a large server won’t be too onerous to copy this way.

If container 1 goes down, you change your IP for the site at your domain service provider, adjust your router forwarding settings at server2 and literally this works out of the box. It’s real “easy” to do if you use lxc, but if you don’t then, well, that’s something you have to learn too.

And I mean EVERYTHING works - usernames, passwords, file links, all settings of every app, customization etc… EVERYTHING. If you can afford the HD storage, include the nextcloud-data folder in the container too (the default in fact for the way Nextcloud is setup), as then even that gets backed up.

You can cron the server copy --refresh option. It’s so fast, you can run it more than daily if you want.

Personally I love LXD - not just for this reason, but this is a good one!