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

View file

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