logoalt Hacker News

creatonez05/01/20251 replyview on HN

> You can't copy the file of a running, active db receiving updates, that can only result in corruption

To push back against "only" -- there is actually one scenario where this works. Copying a file or a subvolume on Btrfs or ZFS can be done atomically, so if it's an ACID database or an LSM tree, in the worst case it will just rollback. Of course, if it's multiple files you have to take care to wrap them in a subvolume so that all of them are copied in the same transaction, simply using `cp --reflink=always` won't do.

Possibly freezing the process with SIGSTOP would yield the same result, but I wouldn't count on that


Replies

lmz05/01/2025

It can't be done without fs specific snapshots - otherwise how would it distinguish between a cp/rsync needing consistent reads vs another sqlite client wanting the newest data?

show 2 replies