While diffing mounted snapshots would work, it sounds like it could be horribly slow in many cases.
Is there btrfs specific functionality for diffing snapshots? (I was unable to find any in the docs)
While diffing mounted snapshots would work, it sounds like it could be horribly slow in many cases.
Is there btrfs specific functionality for diffing snapshots? (I was unable to find any in the docs)
btrfs send
, which appeared in Linux 3.6 (2012), "generates a stream of changes between two subvolume snapshots." You can use it just to produce a fast metadata comparison by adding the--no-data
flag.Normally, you would drop the
--no-data
flag and pipe the output intobtrfs receive
, to do incremental backups. For example, if/snapshots/parent
already exists at/backup/snapshots/parent
,btrfs send
would stream only those changes to the/backup
filesystem:I'm running Debian stable which
doesdid not havebtrfs send
, so I looked to a solution usingbtrfs subvolume find-new
.If you have snapshot1 and snapshot2 and you want to know what changed in the later one, snapshot 2, since snapshot1 was made you can use the script below which provides
which will list all files changed in newsnapshot/ since oldsnapshot/.
To explain:
btrfs subvolume find-new
finds files changed after a particular 'generation' of snapshot. It also reports the current generation number.Caveats
e.g. take the daily snapshot of a subvolume case:
What changed between snap1 and snap2?
So we can see the new file, see the modified file, but the deletion is not reported. This is because the command reports on files that exist, not ones that now don't.
What changed between snap2 and the live subvolume?
the renamed file is not reported. Its data has not changed.
Now what if we add data to the renamed file
OK, makes sense. But let's make a new file
eh! where's lala?. If you add another file,
lala
appears. So this behaviour is a bit odd. Which is probably why the wiki says:However, the oddness comes when you compare a live subvolume against a previous state, not when you're comparing (read-only) snapshots. So this could still be useful unless you want to also identify deleted files.
This is supported by the snapshot convenience tool
snapper
.sudo snapper -c config diff 445..446
Of course this requires you to be using
snapper
for your snapshots.This snapshot ids can be found using
snapper list -a
. Unfortunately at the time of writing snapper did not support list snapshots for a single config, though these numbers can be found from subvolume names.Current solution:
The backup utility
btrbk
(https://github.com/digint/btrbk) also has adiff
(and also aextents diff
) subcommand.