Btrfs receive data integrity verification in AlmaLinux 9
0 reputation · 13 Mar 2024, 07:50 UTC
0 reputation · 13 Mar 2024, 07:50 UTC
AlmaLinux 9 supports the Btrfs filesystem, enabling the use of btrfs send and btrfs receive for incremental backups and snapshot restoration. While these tools facilitate the movement of subvolumes between disks or hosts, the restoration process focuses on the transfer of data blocks rather than an integrated verification of the recovered files.
Current workflows require a separate post-restore phase to ensure that the data on the target volume is consistent and free of corruption. There is uncertainty regarding whether the receive operation provides implicit validation or if manual intervention is the only way to guarantee integrity.
btrfs receive perform any internal checksum validation during the restoration process?btrfs scrub the recommended method for verifying restored snapshot integrity, or are there more efficient filesystem-level checks?Yes, btrfs receive validates checksums inline during restoration. The send stream carries CRC32C checksums for every data and metadata block; receive verifies each block before committing it. A mismatch aborts the operation with a non-zero exit code.
Yes, btrfs scrub is the recommended post-restore integrity check. No more efficient filesystem-level alternative exists. Scrub reads all allocated blocks, verifies stored checksums, and repairs from redundant copies when the RAID profile allows (RAID1, RAID1c3, RAID5/6).
btrfs receive Actually Checksbtrfs send stream for every block.receive cannot see.btrfs check --readonly requires unmounting and is slower.receive exited cleanly:
btrfs receive /target/path < backup.stream
if [ $? -ne 0 ]; then echo "Receive failed: checksum mismatch"; exit 1; fi
btrfs scrub start /target/mountpoint
btrfs scrub status /target/mountpoint
# Wait until "Status: finished" then verify "Error summary: 0"
uname -r (expect 5.14.*) and lsmod | grep btrfs.What RAID profile does the target filesystem use? btrfs filesystem df /mountpoint will show RAID1, RAID5, single, etc. On single or RAID0, scrub detects but cannot repair corruption; you would need a separate backup copy for recovery.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.