digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.6k stars 117 forks source link

Clarification about raw encrypted backups #525

Open luigir-it opened 1 year ago

luigir-it commented 1 year ago

Hello. I'm learning this software, and so far I really like it. After making and restoring local snapshots, I'm trying to make an encrypted copy of a subvolume to an external hard disk, formatted in NTFS. I have the following questions

1) If my backup is encrypted, how can btrbk make an incremental backup? How does it know what changed? 2) Before sending the source to raw, it makes a snapshot of the volume I want to backup. But after the backup is done, the snapshot is not removed, is this the default behavior? Can I safely delete the snapshot afterward? 3) If I want to restore the backup, first I decrypt it, then extract it and after that? Does the btrfs-send&btrfs-receive works with raw .btrfs file? 4) suppose I have a parent backup B1, an incremental backup b1 and a second incremental backup b2 (raw encrypted as described). I don't understand the hint in the ReadMe. How do I restore b2? Should I restore B1 and b1 first and than b2? But how? 5) suppose I want another (encrypted raw) copy to a second external disk, because of redundancy. How does archive differs from just copy paste the raw and metedata files to the second external disk? Or maybe just create a second backup (config identical to the first exept for target path)?

I'm using this configuration: https://pastebin.com/JG3K1SvN And this is the output it produces when sudo btrbk -c ~/btrbk/eliminami -v run : https://pastebin.com/1aGR5rkb

Edit: if this is not clear enough, please tell me. English is not my main language.

luigir-it commented 1 year ago

After some trial and error, I guessed an answer to those questions, I'm sharing so that maybe it can help somebody

  1. When you instruct btrbk to do a new backup, it creates a local snapshot of your subvolume, compares the changes with the local snapshot it made during the previous backup process and than send the incremental data stream to the backup location. So the backup location is needed only to save new data.
  2. The previous answers this. AFAIU you can safely delete all the local snapshots except for the latest one. This way you can check what changed from your previous backup up to now. If you delete the latest snapshot, the changes will be elaborated based on the latest available local snapshot. This means you'll have duplicate data in your target location and an eventual restoration process become more difficult.
  3. First you decrypt it, than extract it and after that you can cat backup.btrfs | sudo btrfs receive /location/to/restore You'll end up with 3 different subvolumes, the first updated until B1, the second until b1 and the last one until b2. If you're intrested only to the latest version of your data, you can sudo btrfs subvolume delete the subvolumes restored from B1 and b1
  4. Yes, you restore first B1, than b1 and after that b2. If you delete the local snapshot that btrbk made while creating b1, and then you create b2, b2 will contain all the changes from B1, so you can skip restoring b1 (but if you do restore it, it won't affect your restoration).
  5. I haven't tried to archive yet.