Created
April 30, 2020 09:46
-
-
Save cosimo/8643b431bd0d15149a66801c977ea7d3 to your computer and use it in GitHub Desktop.
Safe upgrade of a debian system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
OLDDIST=lenny | |
NEWDIST=squeeze | |
BACKUP_DIR="/var/tmp/backup.$OLDDIST" | |
echo "+ Create backup directory" | |
mkdir -p "$BACKUP_DIR" | |
echo "+ Backup system config directories" | |
rsync -ac /etc /var/lib/dpkg /var/lib/apt/extended_states "$BACKUP_DIR" | |
dpkg --get-selections "*" > "$BACKUP_DIR/curr-pkgs.txt" | |
echo "+ Check aptitude in visual mode and press 'g' [ENTER]" | |
read | |
#aptitude | |
echo "+ Check apt preferences (pinnged packages)" | |
if [ -e "/etc/apt/preferences" ]; then | |
echo "Check that you haven't pinned any packages [ENTER]" | |
read | |
fi | |
echo "+ Check dpkg audit log" | |
dpkg --audit | |
if [ "$?" != "0" ]; then | |
echo "Something failed with dpkg --audit ? " | |
exit 1 | |
fi | |
echo "+ Search packages on hold" | |
#aptitude search "~ahold" | |
dpkg --get-selections | grep hold > "$BACKUP_DIR/pkgs-on-hold.txt" | |
if [ "$(grep proposed-updates /etc/apt/sources.list)" != "" ]; then | |
echo "***** You should remove proposed-updates from your sources.list" | |
exit 2 | |
fi | |
if [ "$(grep backports /etc/apt/sources.list)" != "" ]; then | |
echo "***** Backports is enabled. Remove it." | |
exit 3 | |
fi | |
echo "+ Update the sources.list to point to $NEWDIST [ENTER]" | |
read | |
echo "+ Update apt database..." | |
apt-get update | |
echo "+ Disk space check..." | |
apt-get -o APT::Get::Trivial-Only=true dist-upgrade | |
echo "+ Minimal system upgrade [ENTER]" | |
read | |
apt-get upgrade |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment