Deleting old versions of certbot from Snapd


I installed Certbot using Snapd in CentOS. When I installed, the then version was 2.8.0

Now, it is automatically renewed to 2.9.0

My question is, Can I delete the 2.8.0 version from vps? It is around 160MB. I don't have much space in my VPS. So I would like to clean.

In my certbot directory, /var/lib/snapd/snap/certbot , there are 2 folders.
3566 and 3643

I understand, 3643 is the new version, 2.9.0 and 3566 is 2.8.0

My question is Can I delete this folder, 3566 safely? Any problems would be there?

While running, df -m, command, I get the output like this.

Filesystem 1M-blocks Used Available Use% Mounted on
devtmpfs 4 0 4 0% /dev
tmpfs 230 1 229 1% /dev/shm
tmpfs 92 10 83 10% /run
/dev/vda1 10173 3697 6477 37% /
/dev/loop1 64 64 0 100% /var/lib/snapd/snap/core20/2105
/dev/loop2 41 41 0 100% /var/lib/snapd/snap/snapd/20290
/dev/loop0 45 45 0 100% /var/lib/snapd/snap/certbot/3566
/dev/loop3 41 41 0 100% /var/lib/snapd/snap/snapd/20671
/dev/loop4 46 46 0 100% /var/lib/snapd/snap/certbot/3643
tmpfs 46 1 46 1% /run/user/0

Please advise.

Just like arbitrarily deleting files and folders from /etc/letsencrypt can cause you problems, deleting files managed bysnapd can also have undesirable results. You should use the snap command to manage files installed by Snap apps.

An internet search will yield pages that explain in more detail, such as this one.

If 160MB of used disk is impacting your VPS, you may be better off either expanding the VPS or moving some of its data contents to another storage medium.

4 Likes (stolen from Stack Exchange or similar some years ago)

 #Removes old revisions of snaps
 set -eu
 LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
     while read snapname revision; do
         snap remove "$snapname" --revision="$revision"

you can run it on a cron job if you want but snap only keeps one prior version for each snap anyway so unless you're very tight on disk space you can generally ignore it