how to replay a snapshot (btrfs) ?

Rashkae ubuntu at tigershaunt.com
Wed Jul 27 19:37:07 UTC 2016


On 16-07-27 12:47 PM, Lentes, Bernd wrote:
> ----- On Jul 27, 2016, at 1:20 PM, Bernd Lentes bernd.lentes at helmholtz-muenchen.de wrote:
>>> root at ubuntu:/mnt/root# ll
>>> total 16
>>> drwxr-xr-x 1 root root  16 Jul 27 07:34 ./
>>> drwxr-xr-x 1 root root  60 Jul 26 20:01 ../
>>> drwxr-xr-x 1 root root  26 Jul 19 17:51 @home/
>>> drwxr-xr-x 1 root root 252 Jul 26 18:12 old/
>>>
>>> root at ubuntu:/mnt/root# btrfs sub snap old/old/snapshots/root_190720162124/ @
>>> Create a snapshot of 'old/old/snapshots/root_190720162124/' in './@'
>>>
>>> root at ubuntu:/mnt/root# btrfs sub list .
>>> ID 257 gen 39434 top level 5 path old
>>> ID 258 gen 39390 top level 5 path @home
>>> ID 285 gen 39435 top level 257 path old/old/snapshots/root_190720162124
>>> ID 300 gen 39222 top level 257 path old/@
>>> ID 301 gen 39435 top level 5 path @
>>>
>>> question:
>>> in /mnt/root i see the snapshots which are located under the default volume (5)
>>> ?
>>> But i just see them if my default volume is 5 ?
>>>
>> now, what is general the best way to create and restore snapshots ?
>> I'd like to create manually snapshots from / before changing the configuration.
>> Would it be a good idea to create a subvolume for the snapshots directly under the default
>> subvolume (ID 5) ?
>> How can i achieve that ?
> I succeeded. I mounted the default volume from BTRFS (ID 5) again and created
> there a subvolume for the snapshots:
>
> root at PC65472:/# btrfs sub create /mnt/root/snapshot
> Create subvolume '/mnt/root/snapshot'
>
> root at PC65472:/# btrfs sub list /
> ID 257 gen 39434 top level 5 path old
> ID 258 gen 39390 top level 5 path @home
> ID 285 gen 39435 top level 257 path old/old/snapshots/root_190720162124
> ID 300 gen 39222 top level 257 path old/@
> ID 301 gen 39772 top level 5 path @
> ID 305 gen 39772 top level 5 path snapshot
>
> Fine. How to continue now with a snapshot ?
>
> Mounting the snapshot subvolume:
> root at PC65472:/# mount /dev/vg1/lv_root /snap -o subvol=snapshot
>
> Create a snapshot:
> root at PC65472:/# btrfs sub snap / /snap/root270720161800
> Create a snapshot of '/' in '/snap/root270720161800'
>
> Fiddeling around.
>
> Decide to use the snapshot.
>
> Rename @:
> root at PC65472:/mnt/root# mv @ @_old
>
> Create a snapshot from the snapshot:
>
> root at PC65472:/mnt/root# btrfs sub snap /snap/root270720161800/ @
> Create a snapshot of '/snap/root270720161800/' in './@'
>
> Reboot.
>
> Fine. Succeeded. Is that an appropriate way ?
> I think it's ok. No live cd, just one reboot necessary.
>


Looks ok to me.  I just mount my device when I want to create snapshots, 
rather than mounting the snapshot subvolume, but I can't think any 
reason not do it the way you've described.

The only thing I would I would advise, however, especially since you are 
making your snapshot folder accessible, is to make your snapshots read-only.

btrfs sub snap -r / /snap/root270720161800

Restore or roll-back is the same as you've already figured out.  But if you don't make the snapshot read-only, there's no way to assure that the files of the snaphot are not changed/deleted along the way.







More information about the ubuntu-users mailing list