Snapper auto cleanup does not seem to work

This is the content of my /etc/snapper/configs/root



# subvolume to snapshot
SUBVOLUME="/"


# filesystem type
FSTYPE="btrfs"




# btrfs qgroup for space aware cleanup algorithms
QGROUP="1/0"




# fraction of the filesystems space the snapshots may use
SPACE_LIMIT="0.25"




# users and groups allowed to work with config
ALLOW_USERS=""
ALLOW_GROUPS=""


# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
# directory
SYNC_ACL="no"




# start comparing pre- and post-snapshot in background after creating
# post-snapshot
BACKGROUND_COMPARISON="yes"




# run daily number cleanup
NUMBER_CLEANUP="yes"


# limit for number cleanup
NUMBER_MIN_AGE="1800"
NUMBER_LIMIT="2-6"
NUMBER_LIMIT_IMPORTANT="4-8"




# create hourly snapshots
TIMELINE_CREATE="no"


# cleanup hourly snapshots after some time
TIMELINE_CLEANUP="yes"


# limits for timeline cleanup
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="5"
TIMELINE_LIMIT_DAILY="7"
TIMELINE_LIMIT_WEEKLY="0"
TIMELINE_LIMIT_MONTHLY="0"
TIMELINE_LIMIT_YEARLY="0"




# cleanup empty pre-post-pairs
EMPTY_PRE_POST_CLEANUP="yes"


# limits for empty pre-post-pair cleanup
EMPTY_PRE_POST_MIN_AGE="1800"



And this is the output of sudo snapper ls:

Type   | #   | Pre # | Date                     | User | Cleanup | Description           | Userdata     -------+-----+-------+--------------------------+------+---------+-----------------------+--------------
single | 0   |       |                          | root |         | current               |              
single | 1   |       | Tue Oct  3 18:04:44 2017 | root | number  | first root filesystem |              
pre    | 670 |       | Thu Feb  1 20:33:33 2018 | root | number  | zypp(zypper)          | important=yes
pre    | 677 |       | Sat Feb  3 01:38:14 2018 | root | number  | zypp(zypper)          | important=yes
pre    | 678 |       | Sat Feb  3 11:01:59 2018 | root | number  | zypp(zypper)          | important=yes
pre    | 679 |       | Sun Feb  4 21:22:48 2018 | root | number  | zypp(zypper)          | important=yes
post   | 680 | 679   | Sun Feb  4 23:22:33 2018 | root | number  |                       | important=yes
pre    | 694 |       | Wed Feb  7 17:18:43 2018 | root | number  | yast scanner          |              
pre    | 695 |       | Wed Feb  7 17:20:49 2018 | root | number  | zypp(ruby.ruby2.5)    | important=no 
post   | 696 | 694   | Wed Feb  7 17:28:17 2018 | root | number  |                       |              
pre    | 697 |       | Fri Feb  9 14:59:38 2018 | root | number  | zypp(zypper)          | important=yes
pre    | 698 |       | Fri Feb  9 15:04:50 2018 | root | number  | zypp(zypper)          | important=yes
post   | 699 | 698   | Fri Feb  9 16:08:25 2018 | root | number  |                       | important=yes
pre    | 700 |       | Sat Feb 10 12:00:36 2018 | root | number  | zypp(zypper)          | important=yes
post   | 701 | 700   | Sat Feb 10 12:37:22 2018 | root | number  |                       | important=yes
single | 702 |       | Sat Feb 10 16:44:48 2018 | root | number  | rollback backup of #1 | important=yes
single | 703 |       | Sat Feb 10 16:44:51 2018 | root |         |                       |              
pre    | 704 |       | Tue Feb 13 14:18:13 2018 | root | number  | zypp(zypper)          | important=yes
post   | 705 | 704   | Tue Feb 13 14:52:57 2018 | root | number  |                       | important=yes
pre    | 706 |       | Wed Feb 14 17:52:06 2018 | root | number  | yast firewall         |              
pre    | 707 |       | Wed Feb 14 17:52:41 2018 | root | number  | zypp(ruby.ruby2.5)    | important=no 
post   | 708 | 707   | Wed Feb 14 17:52:57 2018 | root | number  |                       | important=no 
post   | 709 | 706   | Wed Feb 14 17:54:09 2018 | root | number  |                       |              
pre    | 710 |       | Wed Feb 14 17:54:59 2018 | root | number  | yast firewall         |              
post   | 711 | 710   | Wed Feb 14 17:56:01 2018 | root | number  |                       |              
pre    | 712 |       | Wed Feb 14 21:04:03 2018 | root | number  | zypp(zypper)          | important=no 
post   | 713 | 712   | Wed Feb 14 21:05:04 2018 | root | number  |                       | important=no 
pre    | 714 |       | Mon Feb 19 20:33:33 2018 | root | number  | zypp(zypper)          | important=yes
post   | 715 | 714   | Mon Feb 19 20:59:49 2018 | root | number  |                       | important=yes
pre    | 716 |       | Tue Feb 20 10:19:09 2018 | root | number  | zypp(zypper)          | important=no 
post   | 717 | 716   | Tue Feb 20 10:19:51 2018 | root | number  |                       | important=no 
pre    | 718 |       | Tue Feb 20 15:21:51 2018 | root | number  | zypp(zypper)          | important=no 
post   | 719 | 718   | Tue Feb 20 15:31:47 2018 | root | number  |                       | important=no 
pre    | 720 |       | Wed Feb 21 12:11:24 2018 | root | number  | zypp(zypper)          | important=yes
pre    | 721 |       | Wed Feb 21 12:14:16 2018 | root | number  | yast partitioner      |              
pre    | 722 |       | Wed Feb 21 12:14:22 2018 | root | number  | yast firewall         |              
post   | 723 | 722   | Wed Feb 21 12:15:02 2018 | root | number  |                       |              
post   | 724 | 721   | Wed Feb 21 12:15:23 2018 | root | number  |                       |              
pre    | 725 |       | Wed Feb 21 12:15:28 2018 | root | number  | yast snapper          |              
pre    | 726 |       | Wed Feb 21 12:15:34 2018 | root | number  | yast security         |              
post   | 727 | 725   | Wed Feb 21 12:18:26 2018 | root | number  |                       |              
post   | 728 | 726   | Wed Feb 21 12:18:54 2018 | root | number  |                       |              
post   | 729 | 720   | Wed Feb 21 12:46:38 2018 | root | number  |                       | important=yes
pre    | 730 |       | Mon Feb 26 11:25:29 2018 | root | number  | zypp(zypper)          | important=yes
post   | 731 | 730   | Mon Feb 26 11:42:16 2018 | root | number  |                       | important=yes
pre    | 732 |       | Tue Feb 27 09:52:21 2018 | root | number  | zypp(zypper)          | important=no 
post   | 733 | 732   | Tue Feb 27 09:53:21 2018 | root | number  |                       | important=no 
pre    | 734 |       | Tue Feb 27 10:32:08 2018 | root | number  | yast view_anymsg      |              
pre    | 735 |       | Tue Feb 27 10:32:56 2018 | root | number  | zypp(zypper)          | important=no 
post   | 736 | 734   | Tue Feb 27 10:32:58 2018 | root | number  |                       |              
post   | 737 | 735   | Tue Feb 27 10:34:12 2018 | root | number  |                       | important=no 
pre    | 738 |       | Tue Feb 27 11:45:04 2018 | root | number  | zypp(zypper)          | important=no 
post   | 739 | 738   | Tue Feb 27 11:46:22 2018 | root | number  |                       | important=no 
pre    | 740 |       | Tue Feb 27 22:47:17 2018 | root | number  | zypp(zypper)          | important=no 
post   | 741 | 740   | Tue Feb 27 22:49:01 2018 | root | number  |                       | important=no 
pre    | 742 |       | Tue Feb 27 23:39:03 2018 | root | number  | zypp(zypper)          | important=no 
post   | 743 | 742   | Tue Feb 27 23:40:07 2018 | root | number  |                       | important=no 
pre    | 744 |       | Thu Mar  1 18:07:05 2018 | root | number  | zypp(zypper)          | important=no 
post   | 745 | 744   | Thu Mar  1 18:07:34 2018 | root | number  |                       | important=no 
pre    | 746 |       | Thu Mar  1 18:09:55 2018 | root | number  | zypp(zypper)          | important=no 
post   | 747 | 746   | Thu Mar  1 18:10:06 2018 | root | number  |                       | important=no 
pre    | 748 |       | Thu Mar  1 18:27:25 2018 | root | number  | zypp(zypper)          | important=no 
post   | 749 | 748   | Thu Mar  1 18:29:57 2018 | root | number  |                       | important=no 
pre    | 750 |       | Sat Mar  3 10:23:50 2018 | root | number  | zypp(zypper)          | important=no 
post   | 751 | 750   | Sat Mar  3 10:26:19 2018 | root | number  |                       | important=no 
pre    | 752 |       | Sat Mar  3 10:31:38 2018 | root | number  | zypp(zypper)          | important=yes
post   | 753 | 752   | Sat Mar  3 11:56:00 2018 | root | number  |                       | important=yes
pre    | 754 |       | Sat Mar  3 15:16:48 2018 | root | number  | zypp(zypper)          | important=no 
post   | 755 | 754   | Sat Mar  3 15:22:53 2018 | root | number  |                       | important=no 
pre    | 756 |       | Mon Mar  5 15:13:02 2018 | root | number  | zypp(zypper)          | important=no 
post   | 757 | 756   | Mon Mar  5 15:24:04 2018 | root | number  |                       | important=no 
pre    | 758 |       | Mon Mar  5 21:21:13 2018 | root | number  | zypp(zypper)          | important=no 
post   | 759 | 758   | Mon Mar  5 21:21:41 2018 | root | number  |                       | important=no 
pre    | 760 |       | Mon Mar  5 22:18:29 2018 | root | number  | zypp(zypper)          | important=no 
post   | 761 | 760   | Mon Mar  5 22:21:57 2018 | root | number  |                       | important=no 
pre    | 762 |       | Thu Mar  8 18:19:26 2018 | root | number  | zypp(zypper)          | important=no 
post   | 763 | 762   | Thu Mar  8 18:21:48 2018 | root | number  |                       | important=no 
pre    | 764 |       | Thu Mar  8 18:38:31 2018 | root | number  | zypp(zypper)          | important=no 
post   | 765 | 764   | Thu Mar  8 18:38:43 2018 | root | number  |                       | important=no 
pre    | 766 |       | Thu Mar  8 23:25:43 2018 | root | number  | zypp(zypper)          | important=no 
post   | 767 | 766   | Thu Mar  8 23:27:47 2018 | root | number  |                       | important=no 
pre    | 768 |       | Thu Mar  8 23:54:16 2018 | root | number  | zypp(zypper)          | important=no 
pre    | 769 |       | Fri Mar  9 01:03:16 2018 | root | number  | yast sw_single        |              
post   | 770 | 769   | Fri Mar  9 01:07:55 2018 | root | number  |                       |              
pre    | 771 |       | Fri Mar  9 01:16:15 2018 | root | number  | zypp(zypper)          | important=yes
post   | 772 | 771   | Fri Mar  9 02:01:42 2018 | root | number  |                       | important=yes
pre    | 773 |       | Fri Mar  9 10:42:09 2018 | root | number  | zypp(zypper)          | important=no 
pre    | 774 |       | Fri Mar  9 10:49:09 2018 | root | number  | zypp(zypper)          | important=no 
pre    | 775 |       | Fri Mar  9 10:56:27 2018 | root | number  | yast sw_single        |              
post   | 776 | 775   | Fri Mar  9 11:02:44 2018 | root | number  |                       |              
pre    | 777 |       | Fri Mar  9 11:32:17 2018 | root | number  | zypp(zypper)          | important=no 
post   | 778 | 777   | Fri Mar  9 11:34:23 2018 | root | number  |                       | important=no 



The list of current snapshots seem to be too big for the settings of my system.

What is the problem, and how can it be solved?

From a terminal run

sudo snapper -v cleanup number

If an error is reported, then the scheduled cleanup will not complete. I have encountered this problem a few times, through personal stupidity and recently as a result of a roll-back.

I also had this problem in the past, https://forums.opensuse.org/showthread.php/527454-Can-t-delete-Snapper-snapshots

Then, I accidentally deleted the wrong snapshot and wiped the system… Not something that I’m willing to do again.

Even this time, the “guilty” snapshot was a rollback. As a warning and reminder, single snapshots (namely, those that don’t belong to a pre-post pair) that are not listed with a cleaning algorithm, should never be manually deleted, because they actually are the current system.

The problem is that the autocleaner apparently tries to delete them, and when it fails, aborts. All the subsequent snapshots, that can safely manually deleted, are not affected by the cleanup process because of this, stacking up and eating all the disk space.

I had to manually delete those unneeded snapshots because the root partition was running out of space and the system was starting to be a bit unresponsive.

Anyway, the problem persists, this is my current state of sudo snapper ls:

Type   | #   | Pre # | Date                     | User | Cleanup | Description           | Userdata     -------+-----+-------+--------------------------+------+---------+-----------------------+--------------
single | 0   |       |                          | root |         | current               |              
single | 1   |       | Tue Oct  3 18:04:44 2017 | root | number  | first root filesystem |              
single | 703 |       | Sat Feb 10 16:44:51 2018 | root |         |                       |              
pre    | 762 |       | Thu Mar  8 18:19:26 2018 | root | number  | zypp(zypper)          | important=no 
post   | 763 | 762   | Thu Mar  8 18:21:48 2018 | root | number  |                       | important=no 
pre    | 764 |       | Thu Mar  8 18:38:31 2018 | root | number  | zypp(zypper)          | important=no 
post   | 765 | 764   | Thu Mar  8 18:38:43 2018 | root | number  |                       | important=no 
pre    | 766 |       | Thu Mar  8 23:25:43 2018 | root | number  | zypp(zypper)          | important=no 
post   | 767 | 766   | Thu Mar  8 23:27:47 2018 | root | number  |                       | important=no 
pre    | 768 |       | Thu Mar  8 23:54:16 2018 | root | number  | zypp(zypper)          | important=no 
pre    | 769 |       | Fri Mar  9 01:03:16 2018 | root | number  | yast sw_single        |              
post   | 770 | 769   | Fri Mar  9 01:07:55 2018 | root | number  |                       |              
pre    | 771 |       | Fri Mar  9 01:16:15 2018 | root | number  | zypp(zypper)          | important=yes
post   | 772 | 771   | Fri Mar  9 02:01:42 2018 | root | number  |                       | important=yes
pre    | 773 |       | Fri Mar  9 10:42:09 2018 | root | number  | zypp(zypper)          | important=no 
pre    | 774 |       | Fri Mar  9 10:49:09 2018 | root | number  | zypp(zypper)          | important=no 
pre    | 775 |       | Fri Mar  9 10:56:27 2018 | root | number  | yast sw_single        |              
post   | 776 | 775   | Fri Mar  9 11:02:44 2018 | root | number  |                       |              
pre    | 777 |       | Fri Mar  9 11:32:17 2018 | root | number  | zypp(zypper)          | important=no 
post   | 778 | 777   | Fri Mar  9 11:34:23 2018 | root | number  |                       | important=no 
pre    | 779 |       | Fri Mar  9 12:53:23 2018 | root | number  | yast partitioner      |              
post   | 780 | 779   | Fri Mar  9 12:56:36 2018 | root | number  |                       |              



Snapshot 703 is the offender here. Apparently, snapshot 0, labeled as current, is just hard-linking it, or something similar.

I don’t really know, I just need a solution that works, that let me perform rollbacks in the rare cases where it is needed, and that keep behaving normally afterwards, by cleaning up unneded snapshots.

And by the way, this is the output of sudo snapper -v cleanup number:

[sudo] password for root:  
Deleting snapshot from root:
1
Deleting snapshot failed.


Some more research led me to this: snapper/btrfs fails to adjust the subvolume id after a rollback - Install/Boot/Login - openSUSE Forums

Quoting from that thread:

Since that thread and the relative bugreport are not so recent, can someone confirm that the command


btrfs subvolume delete .snapshots/1/snapshot/var/lib/machines

is safe and that it will solve this problem?

I can’t help you with that. But your earlier comment on snapshot 703 being the culprit, run

sudo btrfs subvolume get-default /

I think that is your actual boot snapshot.

I have a similar snapshot listing to you, and cleanup does not try to get rid of snapshot 1.

As expected, the system was booted from 703:

~> sudo btrfs subvolume get-default /
[sudo] password di root:  
ID 1038 gen 175808 top level 258 path @/.snapshots/703/snapshot


In your snapshot list, snapshot 1 has the cleanup field set to ‘number’.

I would use yast to modify that to use nothing. You can also do it from a command line, buty I think yast is simpler.

The cleanup process should then work.

Thank you, AFAIK, this removed snapshot 1 from the cleanup algorithm, so when it is called, it should skip it and work with the later ones, is that right?

What about snapshot 703?

I believe so. You can

sudo snapper -v cleanup number

and it should run without an error, although there may be nothing to clean up.

Snapshot 703 is your boot snapshot, you can’t delete it. It does not have “cleanup” set so it should not effect the clean up process.

Anything more in advice will have to come from one of the many forum experts.