Backing Up (and Restoring) a Nextcloud Server

  • 390 views. Added .

Today, I'll demonstrate how to back up the essential components of your Nextcloud server (including your data.) Then, we'll simulate a server failure, and I'll demonstrate how to restore Nextcloud back onto your server.

If you find yourself rebuilding your Nextcloud server, all of the prerequisite commands (for installing the LAMP stack, setting up TLS, etc.) can be found on the NOTS Wiki:

Comments (log in to post)

Alternative Backup Tip:

If you run your Nextcloud server on a local PC, I recommend using a cloning program (such as Clonezilla) to clone an entire drive.  It's a very simple process and avoids having to rebuild the OS, installing packages, restoring Nextcloud, and rewriting all of your OS settings.

1. Shutdown your server.
2. Insert Clonezilla thumb drive into a USB port and boot from the thumb drive.
3.  Follow on screen prompts, plug in external hard disk, and save image to hard disk.   I recommend using the "Beginner Mode" to keep it simple.
A restore is just as simple and BOTH your Nextcloud AND your OS are completely restored.  I use an 1 TB hard disk (exFat formatted) that I had lying around to store a timeline of multiple images.  Image files can be quickly duplicated and stored off-site.  

I also bought a second identical PC server (I use an inexpensive Intel NUC for my servers)  so that I can make changes and try upgrades without taking down the office server.   If the office server hardware fails, I can simply plug in the backup hardware and be running in less than a minute.  I back up once a week to avoid significant data loss.  The clone of my home office server takes about 15 minutes to complete.

I realize there are advantages to hosting a server online, but I prefer the security of having my data on a server in my office.  Call me old-school, but there is something reassuring about having a physical copy of your data in your hands.
I'd love to have my servers self-hosted again at some point. When NOTS has an office, I'll be able to do that again.

For less intrusive and faster backups than Clonezilla, you can also run your server in a virtual machine, such as VirtualBox. That way, you can take a VirtualBox snapshot (which takes seconds rather than minutes) and copy the VM directory to another drive. Restoring is also much simpler because you don't need to match any hardware requirements, any machine with VirtualBox (or your preferred VM program) can be up and running with a few clicks. I ran the NOTS web server that way for at least a year before I switched to cloud hosting.

Cloning the entire server doesn't really involve knowing the workings and layout of Nextcloud, though, which is why it's out of scope for this particular video.
I would have liked to see a script defined for the server backup.  Presumably a script run from a cronjob.  Maybe beyond the scope of this video, but surely it should have a comment on best practices?
I wonder whether you use rsnapshot, if you do, comments, if not, it may be worth looking at.
Enjoy your videos.