[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: is there a way to revert to a previous, known working set of debian packages?



On Fri, 8 Jan 2010 11:23:44 +0000
Jurriaan <thunder8@xs4all.nl> wrote:
> However, I do wonder if there is any way to make snapshot of the
> current versions of all packages, then update, and then, if
> necessary, revert back to the previous snapshot.

I do my upgrades using a little script.

#!/bin/sh

# /root/bin/getafix
# Script to save packages to be upgraded in /root/lib/upgrade/$DATE 
# using dpkg-repack
# In case something goes wrong, whilst upgrading, a simple dpkg -i /root/lib/upgrade/$DATE/*
# will (hopefully) rebuild a working system.

#set -x

apt-get update

# d-ated dir-ectory
DDIR="/root/lib/upgrades/"`date +%Y-%m-%d_%H:%M:%S`

echo $DDIR

# p-ackages t-o b-e u-pgraded
PTBU=`apt-get -s upgrade | grep "The following packages will be upgraded:" --after-context=1 | grep "^  "`

echo PTBU="->"$PTBU"<-"

if [[ -n $PTBU ]]; then  # PTBU non-zero
    mkdir $DDIR
    cd $DDIR
    dpkg-repack $PTBU
else
    echo "No upgrades"
fi


So if anything goes wrong i only have to 

cd /root/lib/upgrades/`date +%Y-%m-%d_%H:%M:%S`

and 

dpkg -i *


When dist-upgrading this will probably produce tons of packages in /root/lib/upgrades/ 

Another way would be to simply copy the partitions involved (with dd) make the upgrade and write them back i anything goes wrong. 

Cheers

Michael


Reply to: