What to do if you skipped mulitple major releases (snap version)

I accidentally skipped multiple major releases while executing snap refresh nextcloud so occ upgrade couldn’t run because it is not supported.
But what do you do if you accidentally skipped major releases?
I Figured out that you can change the symbolic links to the previous versions in /snap/nextcloud and /var/snap/nextcloud and then restart the nextcloud snap. I was able to get Nextcloud 16 back online with this. It is working exactly like before except for one thing. Snap list still lists Nextcloud as the upgraded 19 Version, so I think this is why I get the following error if I try to do:

snap refresh nextcloud --channel=16/stable
error: cannot perform the following tasks:

  • Run pre-refresh hook of “nextcloud” snap if present (run hook “pre-refresh”: error: cannot find hook “pre-refresh” in “nextcloud”)

Here is some additional info on what I did exactly after that accident of upgrading from 16 to 19.

cd /snap/nextcloud
ll
total 8
drwxr-xr-x 4 root root 4096 Jun 29 16:54 ./
drwxr-xr-x 6 root root 4096 Jun 28 18:52 …/
drwxr-xr-x 25 root root 1101 Oct 25 2019 16739/
drwxr-xr-x 26 root root 502 Jun 24 03:05 21796/
lrwxrwxrwx 1 root root 5 Jun 29 16:54 current → 21796/

rm current
ln -s 16739 current
ll
total 8
drwxr-xr-x 4 root root 4096 Jun 29 16:54 ./
drwxr-xr-x 6 root root 4096 Jun 28 18:52 …/
drwxr-xr-x 25 root root 1101 Oct 25 2019 16739/
drwxr-xr-x 26 root root 502 Jun 24 03:05 21796/
lrwxrwxrwx 1 root root 5 Jun 29 16:54 current → 16739/

snap stop nextcloud
Stopped.

snap start nextcloud
Started.

cd /snap/nextcloud/current/bin/
sudo -i nextcloud.occ upgrade
Nextcloud is already latest version

cd /var/snap/nextcloud/
ll
total 20
drwxr-xr-x 5 root root 4096 Jun 29 17:11 ./
drwxr-xr-x 5 root root 4096 Jun 28 18:52 …/
drwxr-xr-x 8 root root 4096 Nov 7 2019 16739/
drwxr-xr-x 8 root root 4096 Nov 7 2019 21796/
drwxr-xr-x 3 root root 4096 Nov 7 2019 common/
lrwxrwxrwx 1 root root 5 Jun 29 17:11 current → 21796/

rm current
ln -s 16739 current
ll
total 20
drwxr-xr-x 5 root root 4096 Jun 29 17:18 ./
drwxr-xr-x 5 root root 4096 Jun 28 18:52 …/
drwxr-xr-x 8 root root 4096 Nov 7 2019 16739/
drwxr-xr-x 8 root root 4096 Nov 7 2019 21796/
drwxr-xr-x 3 root root 4096 Nov 7 2019 common/
lrwxrwxrwx 1 root root 5 Jun 29 17:18 current → 16739/

snap stop nextcloud
Stopped.

snap start nextcloud
Started.

cd /snap/nextcloud/current/bin/
sudo -i nextcloud.occ upgrade
Nextcloud is already latest version

snap list
Name Version Rev Tracking Publisher Notes
core 16-2.45.1 9436 latest/stable canonicalâś“ core
core18 20200427 1754 latest/stable canonicalâś“ base
nextcloud 19.0.0snap1 21796 latest/stable nextcloudâś“ -

snap refresh nextcloud --channel=16/stable
error: cannot perform the following tasks:

  • Run pre-refresh hook of “nextcloud” snap if present (run hook “pre-refresh”: error: cannot find hook “pre-refresh” in “nextcloud”)

So how do I get snap to list Nextcloud as V16 again as if nothing had happened, so I can try to run the Update incrementally, again, hopefully, like described below?

Update Nextcloud Snap
For updating snaps, use …

cd /snap/nextcloud/current/bin
snap refresh nextcloud --channel=16/stable
sudo -i nextcloud.occ upgrade

(or whatever version you’re on)
Then just keep incrementing the version…
when you’re up to the latest, use

snap refresh nextcloud --channel=stable

But what do you do if you accidentally skipped major releases?

Immediately run sudo snap revert nextcloud and you’ll be right back to where you were before you tried to refresh to the wrong channel. Then you can refresh to the RIGHT channel. I also suggest you remove that new revision though so you can upgrade to it fresh, properly. After you revert and have confirmed that v16 is running fine, run snap list nextcloud --all and grab the revision number of v19. Then run sudo snap remove nextcloud --revision=<the v19 revision>. Important: if you get that revision wrong you could remove v16. Be careful. Once this is good, continue.

I Figured out that you can change the symbolic links to the previous versions in /snap/nextcloud and /var/snap/nextcloud and then restart the nextcloud snap. I was able to get Nextcloud 16 back online with this. It is working exactly like before except for one thing. Snap list still lists Nextcloud as the upgraded 19 Version

Yeah don’t do that. Fix the symlink and then revert, which will do that FOR you in addition to some other stuff that you need. Then snapd knows it happened. Once you revert back to v16, refresh through each major release like this:

$ sudo snap refresh nextcloud --channel=17

Wait until you can access the Nextcloud web interface again, which means that all the upgrade steps finished. Then the next one:

$ sudo snap refresh nextcloud --channel=18

Again, wait. Then finally:

$ sudo snap refresh nextcloud --stable

Of course, that last step assumes that the stable channel contains v19 (which of course it does today). If future readers see this, keep following the pattern until you get to whatever is on stable (e.g. --channel=19 and so on).

Note that this process is documented here.

1 Like