Mirror Nextcloud server with Ubuntu Snap


Continuing the discussion from Mirror Nextcloud server:
With Ubuntu / Snap / Corn / rsync, one can automate I guess.

Snap allows selective backup export or import. Default snap location for backup is /var/snap/nextcloud/common/backups/ and default nextcloud snap user data location is /var/snap/nextcloud/common/nextcloud/data

Refer here → How to backup your instance · nextcloud-snap/nextcloud-snap Wiki (github.com)

Considering you have two separate physical system where one is called Main Server and second one is Backup Server, here is the plan

  1. Install Ubuntu Server / Snap NextCloud on both

  2. Set domain / reverse proxy towards Main Server and keep using it as normal

  3. Keep NextCloud on Maintenance mode on Backup Server.

  4. Setup a schedule corn job on Main System with NextCloud Snap backup command to execute nextclud snap backup (just database and config, not the data) as per your schedule.

  5. Setup a corn job rsync on any of these two server to sync the nextcloud user data directory between two servers as per your schedule.

  6. Setup a corn job rsync on any of these two server to sync the nextcloud backup directory between two servers as per your schedule.

  7. Now the last part is little tricky since snap always generates different folder name for every backup, so it may not be possible to run auto import. So if or when your main server is down, you may need to manually run the snap backup import command with the latest backup directory name to import the latest backup into your Backup Server.

  8. Once the backup import is complete, snap will automatically bring nextcloud out of maintenance mode & you may need to update the DNS of your domain or in case of reverse proxy, update the IP of the backup server to bring it online

Users wont notice, they wont need to do any changes at their end.


1 Like

I have installed NextCloud using its official docker container, does it need to install Snap NextCloud on it? or do other steps differ with containers?


I don’t think you may need to change your installation practice. Stay with Docker if you are comfortable with it.

Rsync and such commands are universal for linux so they should work under any environment. Just the directory structure may be different between Snap and Docker deployment.

I am comfortable with snap so that is what I learnt. I don’t have the required knowledge to suggest steps about docker. May be someone else with detailed knowledge about the docker deployment directory structure may give you a better idea about the process with docker


1 Like

thanks for your time and reply.

1 Like