digint / btrbk

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

[Question] Are there any plans to integrate a restore procedure? #375

Open torvic9 opened 3 years ago

torvic9 commented 3 years ago

Hi,

It would be nice to have a restore function integrated into btrbk. Are there technical reasons why such a function does not (yet) exist? Do you think it would be technically possible to create e.g. a bash script which takes care of that?

Thanks for your good work, I'm enjoying btrbk!

digint commented 3 years ago

I regard it pretty dangerous to automatically restore from backups: e.g. many people backup their root file system, and this is not trivial to restore.

Also there are many scenarios to keep in mind which would make it pretty complicated (i believe i described this in a previous issue, but can't find it right now).

Nevertheless, such a feature /might/ come in the future, don't expect it too soon though.

torvic9 commented 3 years ago

I should have added more precision. I was thinking of some kind of btrbk restore command, which, as an example could be interactive, i.e. show a list of either snapshots or backups which the user can select to restore.

btrbk restore snapshot could then show a list of snapshots, and btrbk restore backup a list of the available backups.

I don't know whether that would be feasible, but my idea was to have an easier command than the usual send/receive.

luxagen commented 2 years ago

It sounds to me like the OP simply wants the "restore" command to temporarily reverse the direction of resume?

If I'm wrong, and this is about re-snapshotting a read-write version of the latest btrbk snapshot for a given name, here's a script (I call it btrs-latest) that should print the name of the latest snapshot in the current directory given one or more prefixes:

#!/bin/bash
for name in "$@"; do
    ls -1d "$name".* | sort | tail -1
done

Say you are currently in the root of the BTRFS volume, and have your snapshots in the '.btrbk' subdirectory. If you run:

btrs-latest $subvolname | xargs -I {} btrfs subvolume snapshot .btrbk/{} $subvolname

That should restore it (make sure a subvol doesn't already exist there first, otherwise it'll create the new snapshot inside it). Note that I haven't tested this last line.