Does BTRFS allow hot snapshots?
Posted by Kitchen_Ad2520@reddit | linuxadmin | View on Reddit | 17 comments
Hi!
I'm going to install a new server and I wanted to know if using BTRFS I'll have the possibility of making hot snapshots.
I usually use debian with ext4 and docker but I would like to be able to take snapshots of the entire system
seiha011@reddit
btrfs and docker? I think there are a few things to consider....
Kitchen_Ad2520@reddit (OP)
Do you mean corrupted files if I recover the system from a snapshot?
0bel1sk@reddit
probably overlay compatibility.
MissionGround1193@reddit
Can you explain more? I use brfs and my docker apps are running on it. I've been running it for a few months. Nothing serious, just a bunch of Arr apps.
draeath@reddit
The storage driver in question is for layer handling, not volumes, as far as I know.
0bel1sk@reddit
awesome if it’s working. i know i had challenges with macos changing file systems a while back, and had to do a little hacking around storage drivers when overlay2 came out. if it works out of the box, then ignore my ignorance.
Kitchen_Ad2520@reddit (OP)
OMG! What setup do you recommend to be able to make hot snapshots of the system in which different services run with Docker?
placated@reddit
Why do you need to snapshot docker services? Docker containers should be immutable. On failure they should be pulled from a docker repo and restarted.
It feels like you’re doing this wrong.
0bel1sk@reddit
i’ve used btfrs and zfs snapshots, both work fine. haven’t really done it with docker, i usually bind mount that kind of data
Kitchen_Ad2520@reddit (OP)
I'm confusing. You say that btrfs and docker is not recommended. My idea was to configure a Debian with the btrfs type system partition and run multiple docker services with their respective persistent volumes on that partition. Have I misunderstood or is that idea not recommended?
0bel1sk@reddit
might be replying to different person. i was just taking a stab at what i thought their hesitation was. i dont see any problem with it. you should get data consistent backups either way.
as with any backups, regular testing is important
draeath@reddit
I don't know what op means, but in my experience the btrfs storage driver for docker / podman is slow as hell.
It takes multiple seconds to create or delete a layer, consistently. On NVME. I don't even have qgroups enabled. I've observed this on several different machines as well.
(zfs also is a little slow, but not as bad)
Worth considering.
seiha011@reddit
no big deal, something to do with the btrfs driver. But I could also be "outdated". have fun
stormcloud-9@reddit
That applies to basically all filesystems. Filesystem support for snapshots doesn't have anything to do with file corruption. It has to do with corruption of the filesystem itself (the metadata).
Think about it, lets say you have a file open for editing. You're changing bytes here and there. Then you take a snapshot while the file is still open. Is the snapshot going to wait for the file to be closed? What if it's open for hours?
Btrfs maintains files in blocks. When one of the blocks changes, it will copy the block, and replace that block in the file. So you can easily have a file with incomplete write in it if it was snapshotted with one block updated, but not a later block.
S0A77@reddit
Yes, of course! It is the main reason to chose btrfs!
You can even send the snapshot to another server to "clone" the file system status.
Kitchen_Ad2520@reddit (OP)
Thanks u/S0A77 Then, i'm going to read how to setup debian with brtfs on a bare metal ovh server.
S0A77@reddit
Never used OVH but I presume it provides pre-installed images of the OS.
You could use even the native compression to improve the efficiency, but it is a bit tricky if you are not proficient in Linux.