I run an instance of the excellent NextCloud software locally on a Raspberry Pi, thanks to the equally excellent NextCloudPi distribution – which bundles all the fiddly bits together and provides an additional set of admin tools (collectively “NCP”, and with each of its sub-tools prefixed “nc-“) to assist with stuff like moving the data-storage location to an external USB drive.
However, I had been very foolish and not set up the automatic updates for the NCP software stack when I initially got everything up and running.
I had been running on NCP 0.6.something and NextCloud 13.something for quite a while, but the current-newest is NCP 1.2.something (and it is strongly recommended to have NCP perform the updates of NextCloud itself).
NCP’s self-updating process is not (currently) set up to cope with trying to bridge version-differences as big as the one I had built up, so it failed and left the NCP web panel in a slightly confused and misbehaving state. Didn’t break the NextCloud instance itself, which was nice, but I was still going to have to do some more-manual work to get things updating nicely.
If you want to follow how I got my outdated NextCloudPi system back to current, when the auto update couldn’t, read on!
1. Make Manual Backups
Using the NCP- tools via SSH, I did both a config-export (with nc-export-ncp
) and a “backup not including data” (nc-backup
style) to paths on my USB stick.
Then I shut down the Pi and used Win32DiskImager to make backup image files of both the microsd card AND the USB stick (to protect the file data from any chaos-risk) on my PC. I ended up not needing these backups but having them as a safety-net made me more confident.
2. Reflash with the current-newest img file
I downloaded the newest-current NextCloudPi Raspberry Pi img file, wrote it to the microsd card in the normal way and put it back in my Pi as well as connecting the USB data stick. Plugged it back in to power+ethernet, let it boot, find the IP address that DHCP has given it, and did the normal NCP first-run activation process (taking note of the generated passwords).
A little bit of manual re-setting of initial configuration in the NCP web panel (the thing that runs on port 4443) was in order – setting a static IP, activating SSH and setting an initial password, turning on automount for the USB stick.
I did try restoring the config-export but it did not seem to work – maybe the version-gap was too great, maybe the previous failed update-attempt had broken something, or most likely I don’t really understand what that is supposed to do.
After a reboot, the new blank-slate NextCloudPi was running on the expected IP address and I could move on to…
3. Restoring the backup of my NextCloud install
[To be clear, this section is talking about the backup made by the NCP
tool, which produced a “nextcloud-bkp_xxxxxxxx.tar” file.]nc-backup
I chose to do the rest of the config-wrangling over SSH (I much prefer the free Bitvise SSH client for my from-Windows SSHing needs, rather than PuTTY that most people seem to use) from here, but it should be possible to do these steps in the NCP-web interface just as well – although it might be slightly tricky to know the exact filename of your prior backup if you haven’t SSH’d in.
Using the nice menu-based
console tool, I invoked nc-config
nc-restore
and told it the path to my backup file from earlier (which was carefully stored on the usb stick, mounted at /media/USBdrive/, to ensure it was not lost when I reflashed the microsd card).
That worked fine! But, one thing I had not realised – the combination of nc-backup
and nc-restore
also backs up and restores the entire NextCloud software and not just the data/config. So now, I had a system with up-to-date NCP but the version 13 of NextCloud-itself that I had started with. But, still, that’s at least progress in the right direction.
4. Getting NextCloud up to current version
Once my NCP was up-to-date and the underlying OS-side stuff (expected packages and such) was also suitably modernised, all I needed to do was update from NextCloud 13.blah to 15.blah (being, at the time of writing, the newest version of NextCloud properly supported by NCP).
Initially, I tried using nc-update-nextcloud
and accepting the default version-value of “0” which means “update to newest version”. Alas, that failed – NextCloud cannot skip over entire major versions when updating itself (going directly from 13-to-15 was not tolerated). Thankfully, the nc-update-nextcloud
tool was clever enough to take an extra backup beforehand and flawlessly roll-back the failed upgrade.
OK, so I figured out I would need to instruct nc-update-nextcloud
to take me to an intermediate version (14, in my case) first, and then update from that to the most-recent (15).
So, I found the NextCloud Changelog page, looked up the last release for NextCloud 14 (14.0.12) and asked nc-update-nextcloud
for that version instead. Which worked perfectly.
Then once the upgrade to NC 14 had completed, I re-ran nc-update-nextcloud
one last time, asked it for “0” as the version, and it was able to upgrade to NextCloud 15.0.6.1 with no further headaches.
(If I had put this task off much further, NC 16 would have become available for NextCloudPi and I would most likely have had to do an intermediate upgrade to NC 15 first. So if you’re in the same situation and have been neglecting your NextCloudPi, the sooner you get on with sorting it out, the easier it will be.)
5. Finishing up
At some point in this process I also re-configured letsencrypt, turned on ramlogs and some other NCP config options.
My NextCloud instance was happily back up and running, with all the existing users I had configured there and working (the desktop and mobile apps did not even need to be re-authenticated). All files present and correct, happy days!
As a final finishing touch, I made damn sure to enable both nc-autoupdate-nc
and nc-autoupdate-ncp
to hopefully stop me getting in to the same stupid mess again in the future. I think unattended-upgrades
was enabled by default in the newer NCP install? Either that, or I turned that on too.