Comments on Rollback To A Working State With btrfs + apt-btrfs-snapshot On Ubuntu 12.10
This tutorial explains how you can revert failed apt operations (like apt-get upgrade) and roll back to the previous system state with apt-btrfs-snapshot on an Ubuntu 12.10 system that uses the btrfs file system. apt-btrfs-snapshot creates a snapshot of the system before the apt operation. Being able to easily restore the previous system state after a failed apt operation takes away much of the pain system administrators have to deal with normally and is one of the greatest features of the btrfs file system.
6 Comment(s)
Comments
Seems to work fine in Ubuntu 12.04 as well.
Installation and use is exactly the same. I haven't tested very much but the commands are there and the snapshots do get created as they should.
You mention that this reverts the root file system. Does that mean it will revert my documents too? If so, would you mind including that in your introduction?
Anything you'll change in /local or /usr or whereever might be rolled back.
On newer versions of ubuntu, you nolonger need to mount the filesystem to roll back to an apt-btrfs-snapshot. Just run:
~$ sudo apt-btrfs-snapshot list
to list the available snapshots and then run the following to revert to an older snapshot:
~$ sudo apt-btrfs-snapshot set-default @<name-of-snapshot>
Reboot for the changes to take effect.
Also, deleting snapshots is now much more reliable and simple. Again, to list snapshots, run:
~$ sudo apt-btrfs-snapshot list
Then, to delete a snapshot, run:
~$ sudo apt-btrfs-snapshot delete @<name-of-snapshot>
To list by date older than two days, for example, run:
~$ sudo apt-btrfs-snapshot list-older-than 2d
To delete all snapshots older than two days, for example, run:
~$ sudo apt-btrfs-snapshot delete-older-than 2d
The cool thing is that your old default will not be deleted so you can still roll back to that one if you have one set.
Deleting snapshots should take effect immediately.
Finally, if you ever run into the "no space left on device" problem when you boot up, insert a blank pin drive or external hard drive and mount the blank drive at /tmp using the command line. After doing so, you should be able to proceed with deleting older snapshots.
This documentation is useful for system admin who want to rollback root directory if apt-get broken system.
Thanks.
Now it works.
mchid is wrong. I am using Kubuntu 16.04 LTS and when I trie what he said I get "Sorry, your system lacks support for the snapshot feature" plus I had to sudo apt-install apt-btrfs-snapshot, to install the package.