knorrie / python-btrfs

Python Btrfs module
GNU Lesser General Public License v3.0
112 stars 22 forks source link

Question: Managing Subvolumes #28

Closed Ironlenny closed 3 years ago

Ironlenny commented 3 years ago

I'm looking to write a script to manage subvolumes locally and remotely. The idea is a create a "Time Machine" like setup with the additional benefit of copying good blocks from a backup should a checksum fail. I've perused your documentation, but I didn't find any mention of create or deleting subvolumes. I may have missed it, if so could you point me towards it? Is this something your library supports?

knorrie commented 3 years ago

Hi! Ironlenny. Thanks for the question.

One goal of the python-brtfs lib is to implement calling all of the ioctl stuff that exists in kernel space and dealing with all the metadata structs at some point. You are right to notice that I did not get to the subvolume and snapshot stuff yet.

If you are searching for a way to properly progammaticallty do some things that you otherwise would do with btrfs progs commands, like brtfs sub snap foo bar, then there's also the libbtrfsutil stuff already.

Omar did a great job by adding the libbtrfsutil thing to btrfs-progs, which provides a C and Python way to do some actions and deal with resulting data on the same level of abstraction like command line btrfs-progs do.

It's perfectly fine to create a python program that imports both of the libs and combines the strengths of them. If you want to write just a few lines of python to snapshot filesystem path A to B then leverage the 'equal to command line program' libbtrsutil for that. When you actually want to have a look behind the scenes to check what it actually did, then you can use this libs functions again.

So a key thing here to understand is what libs you have available and what abstraction level and audience they're targetting.

Feel free to ask more questions while exploring things.

Hans

Ironlenny commented 3 years ago

Thanks for the detailed response. I didn't know about libbtrfsutil!. As an aside, I do appreciate how helpful you are. Not all maintainers are so eager to answer basic questions.

knorrie commented 3 years ago

Thanks, go try have fun and do stuff and dont hesitate to ask after you get stuck. :)