From d89f0ce632388a8915a330af8dd681e0dbcf2b6c Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 2 Oct 2023 10:20:27 +0200 Subject: backup: download arch packages from mirror before doing the backup --- backup.in | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/backup.in b/backup.in index 2de7384..2d4a046 100755 --- a/backup.in +++ b/backup.in @@ -203,13 +203,69 @@ for toExclude in "${excludes[@]}"; do excludeArgs="${excludeArgs} --exclude ${toExclude}" done -if [ ! -e "${neues}/wip" ]; then - mkdir -p "${neues}/wip" -fi -chmod 750 "${neues}"{,/wip} -chown root:root "${neues}"{,/wip} +mkdir -p "${neues}/wip" +mkdir -p "${neues}/tmp" +chmod 750 "${neues}"{,/wip,/tmp} +chown root:root "${neues}"{,/wip,/tmp} if [ -z "${rsyncShell}" ]; then preConnectHook + if [ -z "${Quelle#*@*:/}" ]; then + ssh "-${ipVer}" "${Quelle%:/}" ' + pacman-conf Architecture + find /var/lib/pacman/local -name desc -exec cat {} + + ' \ + | { + read -r arch + sed -n ' + /^%\(NAME\|VERSION\|ARCH\)%/ { + N + s/\n/ / + p + } + ' \ + | sed ' + N + N + s@^%NAME% \(\S\+\)\n%VERSION% \(\S\+\)\n%ARCH% \(\S\+\)$@\1-\2-\3.pkg.tar.zst@ + t + w /dev/stderr + d + ' \ + | while read -r file; do + cache_file='/var/cache/pacman/pkg/'"${file}" + if [ ! -f "${cache_file}" ]; then + case "${arch}" in + 'x86_64') + for url in \ + 'https://mirror.f4st.host/archlinux/pool/packages/'"${file}" \ + 'https://archive.archlinux.org/packages/'"${file:0:1}"'/'"${file%-*}"'/'"${file}"; do + curl -Lo "${cache_file}" "${url}" || continue + tar --zstd -tf "${cache_file}" >/dev/null 2>&1 && break + done + ;; + 'i486'|'i686'|'pentium4') + for url in \ + 'https://mirror.archlinux32.org/pool/'"${file}" \ + 'https://archive.archlinux32.org/packages/'"${file:0:1}"'/'"${file%-*}"'/'"${file}"; do + curl -Lo "${cache_file}" "${url}" || continue + tar --zstd -tf "${cache_file}" >/dev/null 2>&1 && break + done + ;; + *) + for url in \ + 'https://mirror.archlinux.org/'"${arch}"'/'{extra,community,core,alarm,aur}'/'"${file}"; do + curl -Lo "${cache_file}" "${url}" || continue + tar --zstd -tf "${cache_file}" >/dev/null 2>&1 && break + done + ;; + esac + fi + if [ -f "${cache_file}" ]; then + tar -C "${neues:?}/wip/" --zstd -xf "${cache_file}" + fi + done + } + fi rsync ${rsyncOptions} \ ${linkdests} \ ${excludeArgs} \ -- cgit v1.2.3-70-g09d2