linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Is it safe to use snapshot without data as 'btrfs send' parent?
@ 2022-10-22 21:13 Nemcev Aleksey
  2022-10-23  7:01 ` Andrei Borzenkov
  0 siblings, 1 reply; 4+ messages in thread
From: Nemcev Aleksey @ 2022-10-22 21:13 UTC (permalink / raw)
  To: linux-btrfs

Hello Btrfs developers.

Thank you for your great product, Btrfs!

I want to use Btrfs snapshots and 'btrfs send | btrfs receive' features 
to incremental backup my PC to an external drive.
I can do this using commands:
btrfs subvolume snapshot -r subvolume snapshot; btrfs send snapshot -p 
previous_snapshot | btrfs receive backup_drive

But Btrfs snapshots on my PC consume space even for deleted files.
So I can't just remove unused files to free space on my PC if I keep 
parent snapshots for incremental backups on this PC).
I need to do another backup, then remove snapshot left from previous 
backup from my PC to free up space.

I want to use metadata-only snapshots to overcome this issue.

Can I safely use the following chain of commands to keep metadata-only 
snapshot on my PC and keep full snapshots on the
backup drive?

# Initial full backup:
# Create temporary snapshot
btrfs subvolume snapshot -r source/@ source/@_backup
# Send temporary snapshot to the backup drive
btrfs send source/@_backup | btrfs receive backup_drive
# Delete temporary snapshot
btrfs subvolume delete source/@_backup
# Move received on backup drive snapshot to its final name
mv backup_drive/@_backup backup_drive/@_backup1
# Send back metadata-only snapshot to source FS
btrfs send --no-data backup_drive/@_backup1 | btrfs receive 
source/skinny_snapshots

# Incremental backups:
# Create temporary snapshot
btrfs subvolume snapshot -r source/@ source/@_backup
# Send temporary snapshot to the backup drive using metadata-only 
snapshot as parent
btrfs send source/@_backup -p source/skinny_snapshots/@_backup1 | btrfs 
receive backup_drive
# Delete temporary snapshot
btrfs subvolume delete source/@_backup
# Move received on backup drive snapshot to its final name
mv backup_drive/@_backup backup_drive/@_backup2
# Send back metadata-only snapshot to source FS
btrfs send --no-data backup_drive/@_backup2 -p backup_drive/@_backup1 | 
btrfs receive source/skinny_snapshots

I tested this sequence, and it seems to work fine on small test filesystems.
Backups seem to be correct and seem to have all files they should have 
with correct checksums after all.
Source FS frees up space after deleting files while having metadata-only 
snapshots on it.
It's possible to use such "skinny" snapshots as parent for btrfs send 
command.

But I'd like to get confirmation from Btrfs developers:
Is this approach safe?
Can I use it daily and be sure my backups will be consistent?

Thank you.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-23 13:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-22 21:13 Is it safe to use snapshot without data as 'btrfs send' parent? Nemcev Aleksey
2022-10-23  7:01 ` Andrei Borzenkov
2022-10-23  9:32   ` Nemcev Aleksey
2022-10-23 13:54     ` Andrei Borzenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).