Backup strategy on Nextcloud snap

Hello,

I am trying to understand the best backup strategy for my Nextcloud snap instance. I’m currently doing daily backups of the data directory on a remote hard drive via SSH (pull mode) using rsnapshot. I would like to add to the backup what is missing, that is: the application itself, config files, the mysql database, etc. I understand this could be done by doing backups of the /var/snap/nextcloud/ and /snap/nextcloud/ directories.

So, my questions are:

  1. In case of a failure, would I be able to restore my instance with all its users and configuration, on this or on an equivalent device?
  2. What is the difference (apart from restore automation) between my backup strategy and the official one (How to backup your instance · nextcloud-snap/nextcloud-snap Wiki · GitHub)? I don’t want to use this because it would force me to perform a local backup.

Thank you!

Sorry i do not use Snap.

discussion in german

Translation to english:

This is a late answer, but may be of interest to other readers: If you want to symlink the directory /var/snap/nextcloud/common/backups to another drive, you must first allow access to external drives via ‘sudo snap connect nextcloud:removable-media’. Since Nextcloud in snap runs in a chroot environment, you must set the appropriate permissions on the external drive (‘sudo chown -R root:root /media//’ and ‘sudo chmod -R 755 /media//’). After that, the backup works (at least it does for me) without any problems via ‘sudo nextcloud.export’…

DeepL translator

Maybe you can combine it with sshfs. Not tested.

Also you can read the code export-data. There you can find the code for rsync apps, export database, copy configurations and rsync data. It is important that you also try a restore with import-data or with the commands in the code.

Perhaps you can perform both backup and restore manually, in a separate script or in a customised script.

Hi @tc43,

feel free to check out our Nextcloud snap wiki.
You’ll find some helpful information for backup, restore & migrate.

Thank you very much, I’ll give it a try with sshfs!

Hi,
Thank you, I’m not sure if the procedure suggested in the wiki would give me incremental snapshots since they would be stored on a remote machine, but I’ll check if I can adapt it.

@tc43 from what I’ve gathered the snap snapshot method is not incremental but has the added advantage of zero downtime when taking snapshots. Which makes this method great for weekly rotating backups. Similar to LXC or Proxmox container snapshots.

for incremental raw data backup you’ll need to use rsync or my preference rclone for syncing raw data to NAS or cloud or wherever. See https://rclone.org/. An added advantage is easy scripting and automation using cron.

so for 1. your best bet is to use the snap snapshot method. you can automate that using the example script and transfer the snapshot to your target.

for 2. that official (How to backup your instance · nextcloud-snap/nextcloud-snap Wiki · GitHub ) has been revised and you’ve seen the links I’ve given you.

If you’re not keen on saving a “working snap snapshot” locally, you’ll need to do an incremental raw data backup… which is fine, because the snap is very robust and you can always revert if you have issues. BUT you will not be backing up your configs, database and certs.

So you will need to decide if you’re happy having the raw data saved incrementally and in the case of disaster, you’ll need to reinstall the snap (which is a matter of a couple of seconds) configure the snap from scratch, create your users and restore the raw data.

Its all a matter of preference. Take a look at my setup if you like. The containerisation and redundancy is overkill for personal use cases, but really nice :diving_mask::ok_hand: