digint / btrbk

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

perform more extensive checks on dryrun #27

Open grondinm opened 9 years ago

grondinm commented 9 years ago

So i was in the process of encrypting my entire system and recreating all my btrfs volumes/subvolumes in the process i made a mistake and created my snapshot dir as @Backup instead of @Backups like was set up originally and defined in btrbk.conf. When i ran dryrun it did not show me any errors:

btrbk -c /etc/btrbk/btrbk.conf dryrun
--------------------------------------------------------------------------------
Backup Summary (btrbk command line client, version 0.19.2)

    Date:   Thu Jun 11 08:43:35 2015
    Config: /etc/btrbk/btrbk.conf

Legend:
    ===  up-to-date subvolume (source snapshot)
    +++  created subvolume (source snapshot)
    ---  deleted subvolume
    ***  received subvolume (non-incremental)
    >>>  received subvolume (incremental)
--------------------------------------------------------------------------------
/mnt/btrfsroot/@Home
+++ /mnt/btrfsroot/@Backups/@Home.20150611
*** /media/Storage3/Backup/@HomeBackup/@Home.20150611

/mnt/btrfsroot/@Storage
+++ /mnt/btrfsroot/@Backups/@Storage.20150611
*** /media/Storage3/Backup/@StorageBackup/@Storage.20150611

NOTE: Dryrun was active, none of the operations above were actually executed!

but then when i ran run it failed(as it should since the @Backups subvol is not present):

btrbk -v -c /etc/btrbk/btrbk.conf run
btrbk command line client, version 0.19.2  (Thu Jun 11 08:44:04 2015)
Using configuration: /etc/btrbk/btrbk.conf
Creating subvolume snapshot for: /mnt/btrfsroot/@Home
>>> /mnt/btrfsroot/@Backups/@Home.20150611
ERROR: can't access '/mnt/btrfsroot/@Backups'
ERROR: Failed to create btrfs subvolume snapshot: /mnt/btrfsroot/@Home -> /mnt/btrfsroot/@Backups/@Home.20150611
WARNING: Skipping subvolume section: Failed to create snapshot: /mnt/btrfsroot/@Home -> /mnt/btrfsroot/@Backups/@Home.20150611
Creating subvolume snapshot for: /mnt/btrfsroot/@Storage
>>> /mnt/btrfsroot/@Backups/@Storage.20150611
ERROR: can't access '/mnt/btrfsroot/@Backups'
ERROR: Failed to create btrfs subvolume snapshot: /mnt/btrfsroot/@Storage -> /mnt/btrfsroot/@Backups/@Storage.20150611
WARNING: Skipping subvolume section: Failed to create snapshot: /mnt/btrfsroot/@Storage -> /mnt/btrfsroot/@Backups/@Storage.20150611
Completed within: 0s  (Thu Jun 11 08:44:04 2015)
--------------------------------------------------------------------------------
Backup Summary (btrbk command line client, version 0.19.2)

    Date:   Thu Jun 11 08:44:04 2015
    Config: /etc/btrbk/btrbk.conf

Legend:
    ===  up-to-date subvolume (source snapshot)
    +++  created subvolume (source snapshot)
    ---  deleted subvolume
    ***  received subvolume (non-incremental)
    >>>  received subvolume (incremental)
--------------------------------------------------------------------------------
/mnt/btrfsroot/@Home
!!! Aborted: Failed to create snapshot: /mnt/btrfsroot/@Home -> /mnt/btrfsroot/@Backups/@Home.20150611

/mnt/btrfsroot/@Storage
!!! Aborted: Failed to create snapshot: /mnt/btrfsroot/@Storage -> /mnt/btrfsroot/@Backups/@Storage.20150611

NOTE: Some errors occurred, which may result in missing backups!

So it seems that some part of dryrun is not testing for the presence of the snapshot dir as it should.

btrfs subvol list /mnt/btrfsroot
ID 259 gen 9 top level 5 path @Backup
ID 646 gen 1303 top level 5 path @Home
ID 901 gen 1307 top level 5 path @Storage
digint commented 9 years ago

I'm afraid this is the expected behaviour. btrbk does not perform checks on the snapshot_dir, mainly because it can also be a regular directory, and then it will not show up on btrfs subvol list then. This would complicate things on ssh sources, so I decided not to implement checks on this.

Note that there are also other use cases where snapshot creation may fail, and as long as btrfs-progs does not provide a "dry-run" functionality itself, it is almost impossible to really check for all possible errors of the btrfs commands.

I've been thinking of implementing a "btrbk check" action which would do all kind of checking, but for now this is simply "functions as expected"...

grondinm commented 9 years ago

OK but should it not at least check for the exitense of it by doing a sinple ls or in some other way whether or not it's a subvolume would be irrelevant really just a though

digint commented 9 years ago

Originally, I wanted btrbk to depend only on the btrfs command (which makes it much easier to setup a chroot on ssh for example). As btrbk grows, I might need to change this, e.g. for a new "checkconfig" action.