how to replay a snapshot (btrfs) ?

Lentes, Bernd bernd.lentes at helmholtz-muenchen.de
Wed Jul 27 11:20:46 UTC 2016



----- On Jul 27, 2016, at 10:07 AM, Bernd Lentes bernd.lentes at helmholtz-muenchen.de wrote:

> ----- On Jul 26, 2016, at 10:30 PM, Rashkae ubuntu at tigershaunt.com wrote:
> 
>> On 16-07-26 04:09 PM, Lentes, Bernd wrote:
>>>
>>> root at ubuntu:~# btrfs sub get-default /mnt/root/
>>> ID 5 (FS_TREE)
>>> root at ubuntu:~#
>>> root at ubuntu:~# btrfs sub list /mnt/root/
>>> ID 257 gen 39426 top level 5 path @
>>> ID 258 gen 39390 top level 5 path @home
>>> ID 285 gen 39218 top level 257 path @/old/snapshots/root_190720162124
>>> ID 300 gen 39222 top level 257 path @/@
>>> root at ubuntu:~#
>>> root at ubuntu:~# ll /mnt/root/
>>> total 16
>>> drwxr-xr-x 1 root root  12 Jun  8 15:19 ./
>>> drwxr-xr-x 1 root root  60 Jul 26 20:01 ../
>>> drwxr-xr-x 1 root root 252 Jul 26 18:12 @/
>>> drwxr-xr-x 1 root root  26 Jul 19 17:51 @home/
>>> root at ubuntu:~#
>>>
>> 
>> 
>> Excellent
>> 
>> so from here:
>> 
>> cd /mnt/root
>> mv @ old
>> btrfs sub snap old/old/snapshots/root_190720162124 @
>> 
>> Try reboot
>> 
> 
> 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 ?
> 
> Bernd
> 
> P.S. No you didn't wreck it :-)). It was just late yesterday and i stopped.

now, what is generally 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 the snapshot directly under the default subvolume (ID 5) ?
How can i achieve that ? 
When i create a subvolume for the snapshots, it's always situated under the id of / :

root at PC65472:/# btrfs sub create @snapshot
Create subvolume './@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 39756 top level 5 path @
ID 304 gen 39756 top level 301 path @snapshot

root at PC65472:/# btrfs sub set-default 5 @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 39759 top level 5 path @
ID 304 gen 39756 top level 301 path @snapshot

Changing the default does not help.

I mounted the device and created a directory directly below it, but that does not automatically
create a snapshot:

root at PC65472:/# mount /dev/vg1/lv_root /mnt/root
root at PC65472:/# ll /mnt/root
total 16
drwxr-xr-x 1 root root  18 Jul 27 09:36 ./
drwxr-xr-x 1 root root  18 Jul 27 13:14 ../
drwxr-xr-x 1 root root 262 Jul 27 13:07 @/
drwxr-xr-x 1 root root  26 Jul 19 19:51 @home/
drwxr-xr-x 1 root root 252 Jul 26 20:12 old/

root at PC65472:/# mkdir /mnt/root/@snapshot

root at PC65472:/# ll /mnt/root
total 16
drwxr-xr-x 1 root root  36 Jul 27 13:16 ./
drwxr-xr-x 1 root root  18 Jul 27 13:14 ../
drwxr-xr-x 1 root root 244 Jul 27 13:15 @/
drwxr-xr-x 1 root root  26 Jul 19 19:51 @home/
drwxr-xr-x 1 root root 252 Jul 26 20:12 old/
drwxr-xr-x 1 root root   0 Jul 27 13:16 @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 39765 top level 5 path @


Suse creates additionally subvolumes for some directories like /var/lib, /var/log.
That means that the content of these subvolumes is not included if i make a snapshot of / ?
That would be a good idea, because you don't want to restore the log files or the databases from
some days ago.


Bernd
 

Helmholtz Zentrum Muenchen
Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH)
Ingolstaedter Landstr. 1
85764 Neuherberg
www.helmholtz-muenchen.de
Aufsichtsratsvorsitzende: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrer: Prof. Dr. Guenther Wess, Dr. Alfons Enhsen, Renate Schlusen (komm.)
Registergericht: Amtsgericht Muenchen HRB 6466
USt-IdNr: DE 129521671




More information about the ubuntu-users mailing list