Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I remotely administer a 12.04 LTS desktop and will periodically do sudo apt-get update sudo apt-get upgrade

However, if the upgrade installs something that causes a system issue, I'd like to roll it back to the previous version.

  1. Is there a way to tell what items will be upgrade, along with the from/to versions?
  2. Once the upgrade is done, is there a way to restore the previous version (and all its dependencies).

For example, I see on my local machine, that there is a newer version of the flash player. Historically, I've had numerous issues with flash breaking things, so I'm really concerned about blindly updating on this remote system and not being able to back it out.

Thoughts/suggestions?

share|improve this question
add comment

2 Answers 2

You can display packages that are going to be upgraded and version changes with:

sudo apt-get update
sudo apt-get -V upgrade

The '-V' flag shows you the additional info. As for the snapshots - you really have to roll your own here.

My favourite method for having the rollback ability is using LVM with snapshots on Linux - but the last time I checked, there was no progress on the automated rollback to the chosen snapshot. This might have changed since then (I'd be happy for someone to correct me), but you can always boot using root=/dev/vg0/root-snap kernel parameter (for instance) and then use rsync to sync the snapshot /dev/vg0/root-snap to the original volume /dev/vg0/root and then discard the snapshot. Not ideal but can be automated.

Of course ZFS snapshots rock but there's no official, production-ready ZFS support for Linux (yes, I'm aware of zfsonlinux.org and ZFS-FUSE), so unless you're just playing around, that's not really a feasible option for you.

UPDATE: it looks that we can now rollback (merge in LVM2 parlance) snapshots. So the update would take the following form with LVM2:

  1. Create a 5GB snapshot of your root LV:

    lvcreate -s /dev/vg0/root -L5G -n root-snap

  2. Update the package (as above).

  3. Roll back if necessary by running:

    lvconvert --merge /dev/vg0/root-snap

And because /dev/vg0/root (the original LV) is opened, lvconvert will notify you that the /dev/vg0/root will be rolled back to /dev/vg0/root-snap upon the next activation of this volume. This happens when you run

lvchange -ay /dev/vg0/root

while this LV is closed, which is upon the next boot or after running:

lvchange -an /dev/vg0/root
share|improve this answer
    
LVM just gained support for easy reverting of snapshots. Also consider Btrfs (file system) as of great potential for this task. –  gertvdijk Dec 20 '12 at 1:10
    
Awesome, thanks for the heads up about LVM - I was hoping to hear that since I haven't checked it myself in a while. Btrfs - I've looked into it but after having used ZFS, I'm spoilt :) And I haven't had the time to test btrfs yet - but I definitely will :) –  Marcin Kaminski Dec 20 '12 at 1:16
    
If you install with btrfs, it'll (a) automatically set up /home on a subvolume, and (b) there's the apt-btrfs-snapshot package that automatically takes a snapshot of the root before each dpkg run, and provides an interface for rollback. –  RAOF Dec 20 '12 at 5:29
    
Interesting idea with LVM. On this system (a desktop that I only have remote access to), it is not using LVM. There is a second (unused drive - I have snapshot running on it). Is there a way to (remotely) setup LVM on this system to be able to do the snapshot? Any pointers to instructions (I'm not very familiar with LVM)? –  pcm Dec 20 '12 at 12:43
add comment
  1. Run sudo apt-get update && sudo apt-get -s dist-upgrade to see what's going to be installed and updated (dist-upgrade will not do a release upgrade!). The command is a dry run, so that nothing is actually getting installed.

  2. Make sure there is a system snapshot to restore from. It's not possible to roll/fall/walk/jump/etc back an apt-get command.

Not updating Adobe Flash is a bad idea, and as Flash doesn't usually break anything other then itself, I'd recommend keeping it uptodate, or else, completely removing it.

share|improve this answer
    
This looks like the path I may need to go. I have backups running on the system. Was hoping there was a apt-get downgrade command. RE Flash:certainly, addressing security concerns is important. I've just been bitten a few times by updates totally breaking flash. One remote system has 10.04 and I cannot get Flash to work any more - very frustrating. –  pcm Dec 20 '12 at 12:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.