rollback from a snapshot (BTRFS)

Hi,

i’m still pretty new in BTRFS. I created a snapshot because i made changes in the system. Now system is a bit messed up and i want to roll back to the snapshot.

That’s what i did:

create a read-only snapshot from my root:
btrfs sub snapshot -r / pre_kde

which creates the following snapshot:
/.snapshots/pre_kde

fiddle around

want to roll back

I followed a procedure which succeede under Ubuntu:

mount the default subvolume:
mount /dev/sda2 /mnt/sda2/ -o subvolid=5

cd to there:
cd /mnt/sda2

ls show one directory:
@

create a snapshot from the snapshot:
btrfs sub snap /.snapshots/pre_kde/ @
creates a snapshot @/pre_kde which i didn’t want

rename:
mv -v @ @_alt

create a snapshot from the snapshot (it’s twice, i know :-))
btrfs sub snap @_alt/pre_kde/ @
Now i have a snapshot called @ which is what i wanted

All previous snapshots are now under @_alt, and the desired snapshot is under @.

Reboot

System didn’t boot.

As i said, with Ubuntu i succeeded.

What is wrong ?

Btw: I have the following snapshot (retrieved from the same system, booted with Knoppix):
btrfs sub show @_alt/.snapshots/1/snapshot
/mnt/sda2/@_alt/.snapshots/1/snapshot
Name: snapshot
UUID: 23b8eb3c-13aa-9a4c-af7e-ca04639d968c
Parent UUID: 1baca319-0888-5f49-b87b-bfefb598c77f
Received UUID: -
Creation time: 2016-09-19 17:54:09 +0200
Subvolume ID: 259
Generation: 21834
Gen at creation: 11
Parent ID: 258
Top level ID: 258
Flags: -
Snapshot(s):
@_alt/.snapshots/2/snapshot
@_alt/.snapshots/38/snapshot
@_alt/.snapshots/39/snapshot
@_alt/.snapshots/40/snapshot
@_alt/.snapshots/41/snapshot
@_alt/.snapshots/42/snapshot
@_alt/.snapshots/43/snapshot
@_alt/.snapshots/pre_kde
@_alt/.snapshots/44/snapshot
@_alt/.snapshots/45/snapshot
@_alt/.snapshots/46/snapshot
@_alt/.snapshots/47/snapshot

The snapshot is created on the 19th of september. Yes ?

Inside i have this file:

root@Microknoppix:/mnt/sda2/@_alt/.snapshots/1/snapshot/root# stat .bash_history
Datei: „.bash_history“
Größe: 29585 Blöcke: 64 EA Block: 4096 reguläre Datei
Gerät: 2ah/42d Inode: 159206 Verknüpfungen: 1
Zugriff: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
Zugriff : 2016-09-28 09:36:25.001271739 +0200
Modifiziert: 2016-09-27 19:26:02.323945822 +0200
Geändert : 2016-09-27 19:26:02.323945822 +0200

How can i have inside a snapshot created on 19th of september a file which is modified on 27th of september ?

I thought a snapshot is a freezen image of the particular moment it is created.

Bernd

On 09/28/2016 05:14 AM, berndgsflinux wrote:[color=blue]

i’m still pretty new in BTRFS. I created a snapshot because i made
changes in the system. Now system is a bit messed up and i want to roll
back to the snapshot.

That’s what i did:

create a read-only snapshot from my root:
btrfs sub snapshot -r / pre_kde

which creates the following snapshot:
/.snapshots/pre_kde

fiddle around

want to roll back[/color]

If I understand you correctly, everything from this point on was to try to
roll back to a previous snapshot, and the stuff above was just normal
“create a snapshot before trying something like adding KDE to SLES 12”
stuff. I would probably have used snapper rather than btrfs, since that’s
how this is described int he documentation most of the time, but that’s me.

https://www.suse.com/documentation/sled-12/book_sle_admin/data/sec_snapper_auto.html

All of the rest of your post makes my head swim trying to follow it all,
and here I thought I knew a thing or two about snapshots but perhaps that
should be questioned. In summary, though, I’d probably do things
differently, and have done things differently in the past. Specifically,
use snapper, and when you want to rollback use the ‘rollback’ feature.
Undoing changes this way is outrageously simple, and requires just the one
command. Maybe snapper is hiding some of the details which you are doing,
but my understanding of the rollback (having done it two days ago) is that
it automatically creates a new snapshot of the current system, changes the
default snapshot to the previous one specified by the admin, and that’s
it. There is also an option with SLE to boot directly into an alternate
snapshot from Grub, which you can probably still do now to see if that
helps you.

Keep in mind that some parts of the filesystem are NOT going to be
snapshot-ed because they are in subvolumes excluded on purpose. I do not
know that this will be an issue with KDE stuff, but it’s something to
remember anyway.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

Hi,

i prefer not to use “tools” which hide s.th. from me. The reason i choose linux is that i don’t like tools which automate all the stuff and i don’t know really “what is the system doing” ? If i prefer such a system i choose Windows.
But Suse is going that way. Ok. I apprehend that i have to deal with snapper, but maybe someone explains how snapshoting and rolling back could be done “manually”.

Bernd

On 09/28/2016 07:04 AM, berndgsflinux wrote:[color=blue]

i prefer not to use “tools” which hide s.th. from me. The reason i
choose linux is that i don’t like tools which automate all the stuff and
i don’t know really “what is the system doing” ? If i prefer such a
system i choose Windows.[/color]

Fair enough, but there must be a limit. snapper is not a tool that does
anything that cannot be done other ways, it just simplifies the process so
you do not do it incorrectly, or need to remember all of the various
snapshot IDs, etc. It also automates snapshots, along with a cron job, so
that you have automatic points to which you can restore just in case you
make a mistake without first explicitly creating a snapshot. It is likely
you have these on an hourly basis, if your system is setup by default.
[color=blue]

But Suse is going that way. Ok. I apprehend that i have to deal with
snapper, but maybe someone explains how snapshoting and rolling back
could be done “manually”.[/color]

If you use snapper you can see the snapshots created, and in fact the
rollback function shows you exactly what it does as it creates a read-only
snapshot of the current system, a read-write snapshot of the snapshot to
which you decided to rollback, and then sets the latter as the default
snapshot. Three little commands, simplified by a tool (snapper, or Yast,
or Grub2, or whatever), so nothing proprietary.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…