linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
To: Vytautas D <vytdau@gmail.com>, Btrfs BTRFS <linux-btrfs@vger.kernel.org>
Subject: Re: btrfs ways to travel back in time
Date: Wed, 23 Mar 2016 13:58:08 -0400	[thread overview]
Message-ID: <56F2D930.7000405@gmail.com> (raw)
In-Reply-To: <CAO5K3OeqQUx18gjHNVcOK8=Zo=JLOJhHBJz4jdti73DGakeAfQ@mail.gmail.com>

On 2016-03-23 13:41, Vytautas D wrote:
> I can think of few ways to revert changes with btrfs, but I wonder
> what are the trade-offs between each method and perhaps there is
> already research done on this?
>
> ways to restore a snapshot ( post kernel 3.* ):
> a) via set-default
>   1. btrfs subvolume set-default / $id
>   2. reboot
> b) always mount into snapshot
>   1. mount -o suvol=/.current $disk # at initrd
>   2. btrfs subvol del /.current
>   3. btrfs subvol snapshot /.snapshotA /.current
>   4. reboot
> c) rsync
>   1. rsync $options /.snapshotA /.current
>   2. reboot
>
I can't give much advice on these except to say that the last one listed 
is horribly inefficient and may break things (and use large amounts of 
space).

That said, I can share what I use on my systems to do this.  On all of 
my systems, I intentionally do not use the default subvolume feature, 
and always specify what subvolume to mount.  This allows me to take 
snapshots of the system prior to upgrades (or in other cases where I 
need a snapshot), and then roll back by doing the following:
1. mount LABEL=root /mnt/tmp
2. mv /mnt/tmp/root /mnt/tmp/old-root
3. mv /mnt/tmp/snap1 /mnt/tmp/root
4. touch /mnt/tmp/root/.rollback
3. reboot
6. An custom init script sees the file /.rollback, and then copies over 
any nested subvolumes from the old-root subvolume, renames old-root to 
old-$(date +%FT%T), and deletes /.rollback

This works because mounting with the 'subvol=' mount option only pays 
attention to the path, not the subvolume id or inode.

This can be done on a live system which is actively using the subvolume 
without disrupting normal operation, provided the subvolume itself is 
mounted as part of the FS hierarchy and not implicitly used via nesting. 
  All writes to the mounted subvolume still get sent to the old 
subvolume until the reboot happens (which is usually a good thing).

  reply	other threads:[~2016-03-23 17:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-23 17:41 btrfs ways to travel back in time Vytautas D
2016-03-23 17:58 ` Austin S. Hemmelgarn [this message]
2016-03-23 17:59 ` Alexander Fougner
2016-03-23 23:08   ` Vytautas D
     [not found]   ` <CAO5K3Od8Xi9KAae9gMCWzm4LHxW9mOBU9UPEB7kVqu6uyJ=j9Q@mail.gmail.com>
2016-03-25 14:43     ` Alexander Fougner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56F2D930.7000405@gmail.com \
    --to=ahferroin7@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=vytdau@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).