Added apt repos to backup/restore

This commit is contained in:
Eric Renfro 2023-09-17 16:43:29 -04:00
parent 2f4e9c280b
commit 9769d2a137
1 changed files with 11 additions and 2 deletions

View File

@ -2,9 +2,15 @@
restoreDir="/etc/restore"
function is_bin_in_path {
builtin type -P "$1" &>/dev/null
}
hook_check() {
:
if ! is_bin_in_path aptitude; then
echo "aptitude needs to be installed for backups to work properly."
exit 1
fi
}
hook_pre() {
@ -14,7 +20,9 @@ hook_pre() {
dpkg --get-selections > Package.list
aptitude search --disable-columns -F%p '~i!~M!~v' > InstallOnly.list
#apt-key exportall > /etc/restore/Repo.keys
rsync -avhHi /etc/apt/trusted.gpg.d /etc/restore/
cp -a /etc/apt/sources.list "$restoreDir/"
rsync -avhHi /etc/apt/sources.list.d "$restoreDir/"
rsync -avhHi /etc/apt/trusted.gpg.d "$restoreDir/"
cat > restore.sh <<EOF
#!/bin/bash
@ -43,6 +51,7 @@ if [[ -n "\$install" ]]; then
apt -y install \$install
fi
rsync --ignore-existing -raz sources.list.d/ /etc/apt/sources.list.d/
rsync --ignore-existing -raz trusted.gpg.d/ /etc/apt/trusted.gpg.d/
xargs aptitude --schedule-only install < InstallOnly.list
aptitude install