Welcome to The Privacy Dad's Blog!

Check You Can Restore Your Nextcloud Server from a Saved Disk Image

This post was last edited 1 minute ago.

Nextcloud
Nextcloud Dashboard

One of the best ways to stay private is to just not share it at all. This can be achieved to a degree by running your own cloud server, for example using the open source software Nextcloud.

I would say this is an intermediate level privacy project to set up; you need some experience with the command line, and running your own cloud server requires regular maintenance. You need to keep software updated and make regular backups and images of your server. These images can save you in case of a server crash, in theory.

I've been imaging my Nextcloud server to an external disk for years, but never actually tested if I was able to restore my server from one of these images. I had a mental block about this, worrying my server might crash if I meddled with it, or that I wouldn't have enough understanding to restore the image properly.

I decided to give it a go this week, and am happy to report I got my server up and running on a different computer in no time.

If you run your own cloud server, it's a good idea to test whether you are able to restore your server from saved backups and disk images.

Cloud storage

It's common practice to store just about everything 'in the cloud'. I use Microsoft's One Drive and Google Drive for work, and have used Google Drive and Dropbox in the past for personal documents. Cloud storage is convenient and prevents loss of files, when, for example, a laptop hard drive breaks.

One of the first steps in my personal privacy journey was finding an alternative cloud storage service, one that isn't interested in learning about me from my data and behaviour. I found pCloud and still use that for certain backups today.

Some terminology

Self-hosting means managing your own software on a computer you own. With self-hosted cloud storage, you can connect that computer to your local network (only accessible on your WiFi network), or you can make it public with a domain name, something like myprivatecloud.com. You usually pay for domain names.

People can self-host all kinds of software: a notes app like Joplin, a crypto currency ledger such as a Monero node, a personal media database as an alternative to streaming services, your own email...the list goes on.

If you decide self-host software, you become responsible for everything; this includes updating your operating system and software so they stay secure, checking your hardware is working as expected, and making backups and disk images of your server periodically.

We use the term data backup to describe making a copy of the data that's on your server: your photos, files, notes, etc.

We use the term disk image to describe the process of creating an image of the entire PC: the operating system, the software installed, and all the specific settings. In theory, you should then be able to restore not only your data, but your entire server from the disk image.

Finally, we use the term cloning when we skip the image part and make a direct copy of the server, from one computer to another.

Nextcloud

Nextcloud, as the name suggests, is cloud storage software. Any files, photos or notes you store in Nextcloud can be accessed from your other devices. The data is hidden behind a username and password combination, just like every service on the internet.

Nextcloud is stable and has enjoyed a lot of development by good people. Some educational bodies, provinces and ministries in Europe have been switching over to Nextcloud from Microsoft or Google. This is a fantastic development for privacy.

Nextcloud is free, and there are lots of extra plugins that enable video calls, collaboration on shared documents, hosting files, and many more team-related tasks. I've had to work with both Microsoft Teams and the Google suite, and Nextcloud is a far better experience.

You can run your own home server with Nextcloud. You can stream audio and video from the server to other screens, for example. One summer, I burned all my CDs to MP3 files (yes, manually) and can now stream my music collection via Nextcloud where ever I go.

Nextcloud is popular software with a strong reputation. As a result, there are lots of apps for your smartphone. I take notes using the Nextcloud Notes app, made video calls with family using Nextcloud Talk, and I share files between devices and Android user profiles using the Nextcloud app.

Self-hosting Nextcloud

I've been running a family Nextcloud server for several years now. I am the administrator of the server. It was a somewhat tricky to set up, but I've not had many problems with it since. I use a software management system called Snap to run Nextcloud and it seems to just tick along and update automatically. My personal Nextcloud runs on an older PC sitting on the floor here next to my desk, and I make sure to update the operating system and other software on it.

If you want your Nextcloud server to be accessible from outside your home, you'll need to open your router settings and acquire a domain name. This is not as daunting as it sounds. There is a lot of help online, and I have been able to access my own cloud server from anywhere for years now.

Making data backups and disk images

When one of my kids and their friends began using my Nextcloud server to save their Minecraft worlds, I felt responsible for their data. If something were to go wrong, they could lose whole Minecraft worlds. Any gamer or parent of a gamer knows how important these are to their creators, and how much time and passion goes into building them.

So I began to set reminders to periodically back up all the data saved on my cloud. I store these data backups on external hard drives that I connect to the server PC using USB 3.0 cables and connections.

I also create images of the whole server and save those to an external drive every three months.

Up until recently, I never tested if these backups and disk images would actually help me restore my server in case of a crash or hardware failure. I think I just kind of hoped for the best, trusting the software would do what it promised when I needed it. I was, in a way, sticking my head in the sand about this rather important piece of the self-hosting puzzle.

Restoring Nextcloud from disk image with Clonezilla

I recently freed up a spare little desktop PC, and realised this was an ideal candidate to test if my server disk images actually work.

A disk image has specific settings relevant to the hardware that the image is taken from, but I have noticed over the years that Linux can be flexible and robust when installing it on different types of devices. So I decided to just go for it and restore Nextcloud server from a saved image onto this extra PC, even though it's a different brand. Given that this was not an emergency situation, I had little to lose, a bit like running a fire drill.

The free software I use to create disk images is Clonezilla Live, which you boot up from a USB stick. When you first see the Clonezilla user interface, you might feel you've travelled back to the 1990s. It looks dated, but Clonezilla is reliable, powerful software.

Clonezilla Live
Clonezilla Live has a 90s look

To restore your server from the saved disk image to a PC, I started up Clonezilla Live just as I would when creating an image. You have to tell Clonezilla Live where your image is stored on the external drive. Later, you can indicate you want to restore from image to device.

There is an option to work with partitions, but I just let Clonezilla rebuild the system exactly as it was and wipe the entire drive of the new PC.

Once that was done, I disconnected my original Nextcloud server PC from the internet by pulling the ethernet cable out. I did this to avoid the risk of confusing my router.

After that, I booted up the second PC, now running an exact copy of my Nextcloud server. I found it helpful to attach a mouse, keyboard and monitor screen to that PC, so I could see what was going on and interact physically with it. Bluetooth keyboards are not reliable here, and working remotely from another device is possible but more complicated.

When you restore an image of your server to a different PC, don't forget to add the IP address of that PC to the trusted domains, as otherwise your server will not work and you'll see an error message when you try to log in.

Next, I tested the new Nextcloud server using local host on same device. Just open a browser on the device and type localhost in the search bar. Again, this is all made easier with mouse, keyboard and monitor attached. You should be greeted with the blue Nextcloud login screen.

After this, I checked to see if I could access my Nextcloud account from another device on my local network. To do this, type the LAN IP address of the new server device in a browser on any other device connected to your WiFi network, something like 192.168.223.136. See Documentation section below for relevant commands.

The final step should be to test if I can access my Nextcloud from outside the home, but this is where I admittedly stopped. It's a little more complicated changing IP address settings, but I trust I'll be able to do that should I need to. I didn't want to risk messing up my original working Nextcloud server.

A few tips

To test whether your Nextcloud disk images can save you in an emergency, you'll need a 1GB USB stick with Clonezilla Live (or similar cloning software) installed on it.

You'll also need to find which function key you need to hold down on startup to be able to boot your PC from the USB stick. This can be F2, F9, F10, F12 or Esc—you'll have to read up on your specific device.

This is another reason why I recommend attaching a wired mouse and keyboard to your PC. In my experience, pressing function keys during boot-up on a Bluetooth keyboard is unreliable, especially if it is a fresh install.

I recommend plugging the test PC into the same monitor your normal desktop PC is connected to. This way, you can easily switch between the experimental server and your own notes and information in your browser. My monitor has an HDMI input and a DisplayPort cable, but even one of those old blue VGA screw-on cables should do the trick, allowing you to switch screens with the push of a button.

Next steps

I was glad to learn I am able to restore my Nextcloud server from a disk image. Testing this was long overdue.

Next, I should see if I can restore one of the user data backups I make every month. This would be useful, for example, in cases where Nextcloud is still operable but the data has become corrupted.

I should also learn how to automate backups using the tools available in Linux for that. I have a vague understanding of 'cron-jobs' but need to get my hands dirty.

Lastly, I need to learn how to read and understand my Nextcloud server logs. I'm sure I can learn more here.

Closing thoughts

I hope that my Nextcloud server never crashes, especially not while I'm abroad. The snap version of Nextcloud has been remarkably stable, so much so that I sometimes forget I'm the administrator, or that hardware can fail.

Having now gone through the process of restoring Nextcloud from a disk image makes me feel a little more in control of my own data and more prepared for any surprises.

I highly recommend trying it if you're in the same position I was in, making backups and images but never testing if they actually worked.

Documentation

Nextcloud

How to backup your instance

Next big open source win: Capital of Switzerland moves schools to Nextcloud

How European Schools and Universities Are Replacing Google Workspace with Nextcloud

Snap

pCloud

Tresorit

Proton Drive

Tuta Drive in closed beta

Clonezilla

Clonezilla News

How to use Clonezilla live?

Clonezilla Live on USB flash drive or USB hard drive

Related articles

What Is the Cloud?

My Family Nextcloud Server

Connecting your Wallet to a Monero Node on your Local Network


Finding a device's LAN IP address on Linux

Type ip addr show or hostname -I in the terminal.

Look for a number that looks like this: 192.168.122.236.

See this tutorial for an example of what the output might look like.

Adding a LAN IP address to Nextcloud's trusted domains on Linux

For Nextcloud server to work, the host device's IP address on LAN has to be added to the trusted domains config file. Type these commands:

sudo nextcloud.occ config:system:set trusted_domains 1 --value=x.x.x.x

(x.x.x.x needs to be replaced with the device's local IP address that looks something like 192.168.122.236).

sudo nextcloud.occ config:system:get trusted_domains

sudo snap restart nextcloud

You should then be able to access Nextcloud from any device on your local network by typing the server's IP address into a browser search bar and hitting return.


A note on Nextcloud user data

One aspect that I found strange—and eye-opening!—is that I discovered it is possible make a copy of your friends' and family members' Nextcloud user data, change the permission settings of the copy, and see their files. When I discovered how easy it was to do this, I told everyone who uses my server immediately.

Perhaps that is how companies like Google can read, use and sell our data: they are in full control of the servers we store everything on and therefore own our data.


-----Discuss on Mastodon-----

The Privacy Dad newsletter

Find me on Mastodon.

#backup #clonezilla #digitalprivacy #image #intermediate #journey #linux #nextcloud #server