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

Remove specific file(s) from all snapshots #221

Closed
b0o opened this issue Apr 26, 2018 · 4 comments
Closed

Remove specific file(s) from all snapshots #221

b0o opened this issue Apr 26, 2018 · 4 comments
Labels

Comments

@b0o
Copy link

b0o commented Apr 26, 2018

My primary drive recently reached 100% usage, and I spent a while clearing space by removing old snapshots and deleting as much unnecessary data as possible.

There were quite a few large (10G+) files which I deleted from my home directory, but these files are also in nearly every snapshot on my system (I have 119 of them).

How can I delete them from the snapshots so btrfs can finally reclaim the space?

(I do not care about removing them from backups)

@digint
Copy link
Owner

digint commented Apr 26, 2018

Either remove them by hand:

btrfs subvolume delete /path/to/snapshot

Or use "btrbk prune" with changed preserve flags (either change them in btrbk.conf, or override on command line):

Example: delete all snapshots older than 10 days:

btrbk prune -n --preserve-backups --override=snapshot_preserve="10d" --override=snapshot_preserve_min="10d"

@b0o
Copy link
Author

b0o commented Apr 27, 2018

@digint I'm not interested in deleting the entire snapshot, just a specific file within all snapshots.

@digint
Copy link
Owner

digint commented Apr 27, 2018

Ah I see. Short answer: you can't remove files from snapshots, as these are read-only (by nature, as they share references to each other).

Long answer: you can, but should not. If you are desperate, you can change the subvolumes to read-write using:

btrfs property set -ts /path/to/snapshot ro true

see the btrbk FAQ entry on this.

In order to get some free space (and keep consistency), you must delete the file in all snapshots where referenced. As long as a single snapshot holds a reference to this file the space will not be freed.

@knorrie has some nice tools that might help here: https://github.com/knorrie/python-btrfs

Note that if you do this, you also confuse btrbk incremental feature: Your modified snapshots will still have the same UUID, but don't hold the deleted files anymore.

@b0o
Copy link
Author

b0o commented Apr 28, 2018

@digint Thank you for that awesome answer, that's exactly what I was looking for!

@b0o b0o closed this as completed Apr 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants