Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto cleanup old snapshots on lack of free space #50

Closed
MurzNN opened this issue Feb 26, 2014 · 9 comments
Closed

Auto cleanup old snapshots on lack of free space #50

MurzNN opened this issue Feb 26, 2014 · 9 comments

Comments

@MurzNN
Copy link

MurzNN commented Feb 26, 2014

Snapshots is good, but when free space is going down, users don't have easy ways to free-up space.
They can delete some files, but free space will not increased, and they will be very confused, because they don't know anything about snapshots and how to cleanup them, which snapshot must be deleted for free-up space.

For solve this problem will be good add cron job that checks current free space, and when free space is less than custom limit, do remove older snapshots.

The best way will be detect lacking free space in realtime and report to user ways for free-up space, but I don't know how to do this, so at first cron check will be good.

What do you think about described problem and my solution?

Maybe you have other ideas how we can solve this problem better?

@aschnell
Copy link
Member

Yes, I know this is a problem. My idea is to use btrfs qgroups (quota groups) for this. With those is should be possible to e.g. query to space used by a set of snapshots. Unfortunately qgroups are not mature yet.

Simply watching the free space of the whole filesystem does not work when there are several subvolumes where snapper creates snapshots. E.g. if you have /home/linux and /home/tux you cannot decide whether linux or tux is using the space and you might delete the snapshots of the wrong user.

@MurzNN
Copy link
Author

MurzNN commented Mar 10, 2014

Because free space is shared between all users, removing older snapshot from any user will be good solution for all - this is better that get zero free space.
For example, in /etc/cron.hourly/snapper we can check free space and look at the limit in config file, and cleanup older snapshots if needed (like NUMBER_CLEANUP).

If users don't want to share removing of snapshots, they can use separate btrfs subvolume for each user, and limit total maximum space for each user.

@aschnell
Copy link
Member

But removing snapshots of one user if unfair if that user does not occupies less space that other users. Without qgroups that problem cannot be solved and qgroups are not mature yet.

@aschnell aschnell changed the title Auto cleanup old snapshots on lack free space Auto cleanup old snapshots on lack of free space Sep 19, 2014
@lkraav
Copy link

lkraav commented Nov 23, 2014

What's the situation 8 months later from the last comment @aschnell ?

@aschnell
Copy link
Member

Unfortunately qgroups are still not mature for the usecase. About two month ago I was told that level 0 qgroups are working but level 1 qgroups are not. Level 1 groups are needed.

@MurzNN
Copy link
Author

MurzNN commented Dec 23, 2014

aschnell, can you give me the link with qgroups description? What is difference in level 0 and level 1?
At now I successfully use btrfsQuota.py from https://btrfs.wiki.kernel.org/index.php/Quota_support
and it shows me unshared space for every snapshot:

# btrfsQuota.py /home
subvol                                          group         total    unshared
-------------------------------------------------------------------------------
(unknown)                                       0/5           0.00G       0.00G
@home                                           0/277        19.42G       9.50G
.snapshots                                      0/296         0.00G       0.00G
.snapshots/3/snapshot                           0/320        17.56G       1.07G
.snapshots/49/snapshot                          0/366        17.57G       0.87G
.snapshots/215/snapshot                         0/532        18.25G       0.09G
.snapshots/239/snapshot                         0/556        18.25G       0.08G
.snapshots/263/snapshot                         0/580        18.25G       0.13G
.snapshots/287/snapshot                         0/604        18.25G       0.29G

@MurzNN
Copy link
Author

MurzNN commented Dec 23, 2014

And suggestion for auto cleanup interface. At now KDE Wastebin have good configuration for auto cleanup on lack free space: http://i.imgur.com/nqS02Dy.png
Will be good to see same config for Snapper too.

@aschnell
Copy link
Member

Btrfs quota group documentation is available at http://sensille.com/qgroups.pdf.

@aschnell
Copy link
Member

I have now implemented space aware cleanup using btrfs qgroups, see http://snapper.io/2016/05/18/space-aware-cleanup.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants