nextcloud / vm

💻☁📦 The Nextcloud VM (virtual machine appliance), Home/SME Server and scripts for RPi (4). Community developed and maintained.
https://download.nextcloudvm.com
GNU General Public License v3.0
1.32k stars 663 forks source link

No instructions on how to do backups of Nextcloud VM #2583

Open celeroncool opened 1 year ago

celeroncool commented 1 year ago

How to use GitHub

Is your feature request related to a problem? Please describe. This is a feature request and a problem, as data intergrity and backup are very important in todays IT landscape.

Describe the solution you'd like I would like to have clear instructions, what files do you need to backup, what commands have to be ran so that DB is backed up correctly and lastly, what commands you have to run and in what order to restore from that backup.

Describe alternatives you've considered I am currently trying to implement restic backups of my nextcloud instance. The NCDATA and NCBACKUP folders are self explanatory, and those are easy to integrate to a cron script. But currently there are no docs or guides on how you backup and restore rest of nextcloud VM.

Additional context This guide uses https://github.com/dombyte/Restic-Nextcloud/blob/main/ncbackup.sh mysql dump, but nextcloud VM use PGSQL, which doesnt work with that. It is unclear if you have to set the server to maintenneance mode before you make a SQL snapshot.

enoch85 commented 1 year ago

Just use one of the built in backup methods.

You can reach them by running the menu script.

celeroncool commented 1 year ago

Okay, is there any way to automate taking these backups? For example, I back up my data from NCDATA folder via restic snapshots to a offsite location.

In the menu, is the correct location "Daily Backup Wizard" under "Server Configuration"?

I checked through the script https://github.com/nextcloud/vm/blob/master/not-supported/daily-backup-wizard.sh and seems that you have to have a separate mount to send backups to. My nextcloud is running inside VM, and all data is mounted via NFS to /mnt/ncdata -> script cannot create daily backups.

Is it in development pipeline to add support for these configurations to the backup script?

enoch85 commented 1 year ago

Okay, is there any way to automate taking these backups?

As you already noticed, this is what we have: Run the script and follow the instructions: sudo bash /var/scripts/menu.sh --> Server Configuration --> Daily backup

You are free to configure the script as you please.

We don't have any plans on supporting more than we already have.

You also have some scripts here.

github-tomster commented 7 months ago

as this is a vm one could consider backups at hypervisor level 🤷🏻

celeroncool commented 4 months ago

How would we make sure the database is not locked etc while taking the backup? I think what would work for everyone is to have a script which would dump the DB and configs to x folder (defined in maybe a menu script as a user submitted destination?) in a controlled manner. This way any backup software can save the dump and config safely, and restoration would be as simple as just importing the DB and config file.

enoch85 commented 4 months ago

as this is a vm one could consider backups at hypervisor level 🤷🏻

This.

Depending on system, you will get a full intact clone of your server. Veeam for example works with vMotion. Proxmox with [....] (don't remember the name). Anyway, at VM level is best if you ask me, then you don't need to take any guest system stuff in considerations. Sure, guest level backup are good if you want backups on file level.

celeroncool commented 1 month ago

Taking VM snapshots from hypervisor is not guaranteed to take the DB backup intact! For example, what happens when we take a snapshot of the VM while there are writes to the database? When we then try to restore the VM, the writes could be halfway done or maybe it was in middle of DB row update/delete, the DB will not be OK after restore.

I'll try to create some kind of a bare script which would do the following:

  1. Create backup of all important configs.
  2. Create file based backup of database using database native tools. -> This way restores are guaranteed as they are bundled with the app config taken same time.
  3. Export both in one file date stamped.
  4. Set up cron to automate taking this backup.
enoch85 commented 1 month ago

@celeroncool You and @szaimen maybe could figure something out? :) I'll be reviewing your PR once it's sent here. 👍

github-tomster commented 1 month ago

shut down the vm for backup 💡 'problem' solved ✔

enoch85 commented 1 month ago

shut down the vm for backup 💡 'problem' solved ✔

Haha that's also a way to do it. :D