17

Problem I Faced

  • I installed something that crashed my Wifi drivers that I compiled earlier.
  • Un-installing the same package doesn't helped.
  • Finally, I re-compiled my wifi drivers and things are good.

My Question

But, is there anything like System Restore or System Rollback in Ubuntu/LinuxMint?

  • Is there anything that can undo an apt-get install package command?
4
  • System breakage is a serious problem in Linux, there must be something like System Wide UNDO ? Aug 7, 2011 at 5:16
  • Think outside the windows box (and Google your question). You can just zip up whole chunks of your system, but saying that system failure is a serious problem just isn't true. I run Linux on all of my computers (bleeding-edge Arch Linux, so stability should suffer), and I have yet to see my computer crash or malfunction. Did I mention the computers have been running Arch for 2-4 years each?
    – Blender
    Aug 7, 2011 at 5:26
  • It might have been worth doing an apt-get purge on the package that broke your system since this is supposed to remove any settings associated with it.
    – Col
    Aug 7, 2011 at 8:06
  • @Blender I am a 100% Linux user from 2 years now. Although I hate Windows System restore, but in linux some times X updates break your graphics, there should be something like sandbox or somthing.. to undo that. Aug 7, 2011 at 12:32

6 Answers 6

15

There is a software for Linux called Timeshift exactly for this purpose. Using Timeshift you can take snapshots of your Linux system regularly and restore them whenever you need.

This software brings System Restore feature of Windows to your Linux distribution.

A short description from its official website:

TimeShift for Linux is a application that provides functionality similar to the System Restore feature in Windows and the Time Machine tool in Mac OS. TimeShift protects your system by taking incremental snapshots of the file system at regular intervals. These snapshots can be restored later to bring your system to the exact state it was in at the time when the snapshot was taken.

Snapshots are taken using rsync and hard-links. Common files are shared between snapshots which saves disk space. Each snapshot is a full system backup that can be browsed with a file manager.

2
  • That sounds nice, but if I haven't taken snapshots already, I can not take advantage of it. :/ right?
    – gsamaras
    May 23, 2015 at 15:13
  • That should be part of the official release Mar 22, 2021 at 17:28
10

Actually, there are few things in Ubuntu et al. that will allow you to roll-back changes. Brief below:

  1. /var/backups/dpkg.status.*: this directory keeps a set of log of the last system state prior to an install as follows; /var/backups/dpkg.status.0 is the most recent log prior to a state change (e.g. package install/remove/update ...etc); /var/backups/dpkg.status.?.gz are compressed, archived versions of the logs at various points in time, rotated monthly.
  2. /var/lib/dpkg/status: this is the current state of installed packages. Manually backing this up, or providing a logrotate script in /etc/logrotate.d will ensure schedule snapshots of your system state to your liking.
  3. Roll-back: the corner stone is your previous state /var/backups/dpkg.status.0. Here is a brief step-wise procedure to restore previous package state (note brief and not exhaustive).

    a. cp /var/backups/dpkg.status /var/lib/dpkg/status (will revert back the package state one version back).

    b. dpkg -l | grep ii (will give you a list of supposedly installed packages based on the rolled-back /var/lib/dpkg/status file achieved in step a. above).

    c. dpkg -l | grep ii | awk '{print "apt-get --reinstall -y install", $2}' > /tmp/reinstall && sh /tmp/reinstall (will create a simple one-liner shell script and runs that to reinstall packages determined to have been on the system prior to an apt-get operation)

    d. apt-get --reinstall install ucf (will take care of sanitising /etc config files et. al)

    e. Repeat step c. if/as necessary


With a minimal bit of luck, you should be OK.

7

The complement of apt-get install package is apt-get remove package. To remove all associated settings too, you need to run apt-get purge package.

Note that these commands rely on the uninstallation scripts provided with the package. All packages in the main repository I know of do their job of uninstalling very well. This may not be the case for third-party packages.

As for your driver issue, there are a few possibilities why installing a package broke your wireless driver:

  • The driver has a post-installation hook which is executed when a condition is met, e.g. kernel updates
  • The package overwrote a file that the wireless driver depended on
  • The package in question was a kernel update but the driver does not have a post-installation hook for recompiling the driver (most likely)

As for the "System rollback" / "System Restore" features, the closest feature you'll get is a system image using software like Clonezilla. Unfortunately, this cannot be done within a running system and must be performed from a Live CD.

4

There is no such feature in Ubuntu like "Restore to previous state" in Windows. You should have taken backup, to restore the machine to an earlier stage. Seriously I am also missing this feature. There are many tools but none of them work like Windows Restore point nor Macs Time Machine. Let's see if things get better in backup in Linux.

1

btrfs has/will have some nifty snapshot features that should be able to handle this sort of stuff. Just keep your data in one filesystem and your system in another, and use periodic (daily? weekly?) snapshots, then roll back whenever problems arise.

3
  • 2
    The apt-btrfs-snapshot package automatically snapshots the root subvolume whenever apt does things with packages, making it easy to roll back.
    – psusi
    Mar 20, 2012 at 4:27
  • 1
    Ellaborate.. please. Mar 20, 2012 at 4:52
  • lmgtfy.com?q=apt-btrfs-snapshot Nov 24, 2014 at 21:43
1

Apart from Timeshift and the /var logs mentioned, you can also use etckeeper to guard against ruining config files in your /etc directory and not having backups to restore to. It uses a VCS.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .