What is the best way to backup a nextcloud vm?

Hello!

I just setup nextcloud with snap the way I want on my own mini PC. Now I want to make a backup of it if it got hacked or my RAID fails. I try now to backup it by copying the virtual HDD from Hyper-V but this will take over 10 hours by 3TB virtual HDD size. Is there a better way? I don’t need to backup my files as they are backed up on a different drive seppertly. For it’s important that I can restore the instance in case of a fail and sync all files up again.

The installation is on a VHDD on a iSCSI drive. It can be big as 15TB.

If you don’t care about the files just backup the nextcloud directory (not data directory) along with the database.

Unfortunately, I never bothered to learn how to use snap. Because snap doesn’t interest me.

But that is what you need to do to backup your nextcloud instance, minus the data/files.

@SeeEmAge

see Nextcloud snap wiki and especially Backup, restore & migrate and for your use case Export & import

sudo nextcloud.export -abc

see also script example: rotating Nextcloud snap export script

The nextcloud.export command is right what I want! But how do I get the backup out of my VM to my PC? I am sorry for asking this simple questions but I am still learning with Linux :slight_smile:


EDIT

I just connected the backup folder as external storage in my nextcloud and will download it from there

1 Like

no problem… try using sftp if you have ssh installed in the vm. that’s the easiest I suppose… that’s what the script uses too.

yeah… good workaround :ok_hand: I hadn’t even thought of :diving_mask:

Here’s a simplified backup strategy without the code:

  1. Backup Database: Use a tool like mysqldump to back up your Nextcloud database. This ensures all your configuration and user data is safely stored.
  2. Backup Nextcloud Data and Configuration: Use a backup tool (like rsync) to back up the Nextcloud configuration files and data directory, which holds metadata, user settings, and file indexes.
  3. Incremental Backups: To avoid backing up the entire 3TB every time, use an incremental backup strategy. This only copies the files that have changed since the last backup, saving time and storage space.
  4. Automate Backups: Set up scheduled backups using cron jobs. For example, back up the database daily and the configuration and data weekly. This ensures your backups are always up to date.
  5. Off-Site Backup: Optionally, back up your data to an off-site location like cloud storage or a remote server. This protects your backups in case of physical damage to your primary setup.

This strategy allows for faster, more efficient backups compared to copying the entire virtual HDD and ensures you can restore your Nextcloud instance quickly in the event of a failure.

To back up Nextcloud efficiently, skip the 3TB VHDD copy. Use nextcloud.export for config and database, or tools like rsync and snapshots for key directories (data, config, apps). Hyper-V checkpoints are also a quick option for restoration and syncing.

Thank you for your answers! :slight_smile:
The command

sudo nextcloud.export -abc

Is the best for me at the moment. How do I make a cronjob for doing it every night at 4 AM? I don’t want to brick my system as I worked long for it to work the best for me yet :slight_smile:

@SeeEmAge

try the script

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.