Added ability to failover any missing/unknown packages on restore

This commit is contained in:
Eric Renfro 2023-09-22 10:05:21 -04:00
parent 018bdb500a
commit 944129b407
Signed by: psi-jack
GPG key ID: 14977F3A50D9A5BF

View file

@ -43,6 +43,7 @@ fi
install=""
echo " * Installing required packages"
dpkg-query -s 'rsync' &>/dev/null || install+=" rsync"
dpkg-query -s 'aptitude' &>/dev/null || install+=" aptitude"
dpkg-query -s 'borgbackup' &>/dev/null || install+=" borgbackup"
@ -53,8 +54,10 @@ if [[ -n "\$install" ]]; then
apt -y install \$install
fi
echo " * Enabling 32-bit packages"
grep ':i386' InstallOnly.list &>/dev/null && dpkg --add-architecture i386
echo " * Restoring repositories and keys"
cp -a sources.list /etc/apt/sources.list
rsync --ignore-existing -raz sources.list.d/ /etc/apt/sources.list.d/
rsync --ignore-existing -raz trusted.gpg.d/ /etc/apt/trusted.gpg.d/
@ -62,8 +65,32 @@ rsync --ignore-existing -raz trusted.gpg.d/ /etc/apt/trusted.gpg.d/
apt update
xargs aptitude --schedule-only install < InstallOnly.list
failinstall=""
echo " * Gathering installed packages"
#xargs aptitude --schedule-only install < InstallOnly.list
while read p; do
dpkg-query -s "$p" &>/dev/null
if [[ "$?" -eq 1 ]]; then
aptitude --schedule-only install "$p"
if [[ "$?" -ne 0 ]]; then
if [[ -z "$failinstall" ]]; then
failinstall+="$p"
else
failinstall+=", $p"
fi
fi
fi
done < InstallOnly.list
echo "Packages that failed to schedule for install:"
echo "$failinstall"
echo " * Restoring installed packages (please confirm)"
aptitude install
echo "Packages that failed to schedule for install:"
echo "$failinstall"
EOF
chmod ug+rx restore.sh
popd || exit 2