Assorted shell and Python scripts

+git_backup, ~hyperreal_backup

+55
git_backup
···
+
#!/usr/bin/env bash
+
+
set -euxo pipefail
+
+
if [ -f "${HOME}/.env_common" ]; then
+
source "${HOME}/.env_common"
+
else
+
echo ".env_common not found"
+
exit 1
+
fi
+
+
TILDEGIT_URL="https://tildegit.org"
+
TILDEGIT_CLONE_URL="git@tildegit.org:hyperreal"
+
TILDEGIT_BACKUP_DIR="/naspool/tildegit-backup"
+
KNOT_BACKUP_DIR="/naspool/knot-backup"
+
KNOT_CLONE_URL="git@knot.moonshadow.dev:hyperreal.bsky.moonshadow.dev"
+
+
curl -s -k \
+
-u "hyperreal:${GITEA_TOKEN}" \
+
"${TILDEGIT_URL}/api/v1/user/repos?limit=100&page=1" |
+
jq '.[].name | select(.!="keyoxide_proof")' |
+
tr -d '"' |
+
tee "${TILDEGIT_BACKUP_DIR}/repos.txt"
+
+
while read -r line; do
+
if [ -d "${TILDEGIT_BACKUP_DIR}/${line}" ]; then
+
cd "${TILDEGIT_BACKUP_DIR}/${line}"
+
git pull
+
else
+
cd "${TILDEGIT_BACKUP_DIR}"
+
git clone "${TILDEGIT_CLONE_URL}/${line}.git"
+
fi
+
sleep 30
+
done <"${TILDEGIT_BACKUP_DIR}/repos.txt"
+
+
knot_repos=(
+
"ansible-homelab"
+
"bin"
+
"dotfiles"
+
"hyperreal.coffee"
+
"justfiles"
+
)
+
+
for repo in "${knot_repos[@]}"; do
+
if [ -d "${KNOT_BACKUP_DIR}/${repo}" ]; then
+
cd "${KNOT_BACKUP_DIR}/${repo}"
+
git pull
+
else
+
cd "${KNOT_BACKUP_DIR}"
+
git clone "${KNOT_CLONE_URL}/${repo}"
+
fi
+
sleep 30
+
done
+
+
# vim: ts=4 sw=4 sts=4 ai et ft=bash
+12 -12
hyperreal_backup
···
set -euxo pipefail
if [ ! -f "${HOME}/.env_common" ]; then
-
echo "ERROR: .env_common not found"
-
exit 1
+
echo "ERROR: .env_common not found"
+
exit 1
else
-
source "${HOME}/.env_common"
+
source "${HOME}/.env_common"
fi
curl --retry 3 "${HC_PING_URL}/start"
-
BORG_ARCHIVE=$(borg list ssh://root@hyperreal.carp-wyvern.ts.net/srv/borgbackup/hyperreal | tail -n 1 | awk '{print $1}')
+
BORG_ARCHIVE=$(borg list ssh://u511927@u511927.your-storagebox.de:23/home/borgbackup/hyperreal | tail -n 1 | awk '{print $1}')
ARCHIVE_BASENAME=$(echo "$BORG_ARCHIVE" | cut -d "T" -f 1)
if ! borg export-tar \
-
"ssh://root@hyperreal.carp-wyvern.ts.net/srv/borgbackup/hyperreal::${BORG_ARCHIVE}" \
-
"/naspool/hyperreal_backup/${ARCHIVE_BASENAME}.tar"; then
-
curl --retry 3 "${HC_PING_URL}/fail"
+
"ssh://u511927@u511927.your-storagebox.de:23/home/borgbackup/hyperreal::${BORG_ARCHIVE}" \
+
"/naspool/hyperreal_backup/${ARCHIVE_BASENAME}.tar"; then
+
curl --retry 3 "${HC_PING_URL}/fail"
fi
find /naspool/hyperreal_backup \
-
-maxdepth 1 \
-
-type f \
-
-mtime +7 \
-
-exec rm -fv {} \; ||
-
curl --retry 3 "${HC_PING_URL}/fail"
+
-maxdepth 1 \
+
-type f \
+
-mtime +7 \
+
-exec rm -fv {} \; ||
+
curl --retry 3 "${HC_PING_URL}/fail"
curl --retry 3 "$HC_PING_URL"
-34
tildegit_backup
···
-
#!/usr/bin/env bash
-
-
set -euxo pipefail
-
-
if [ -f "${HOME}/.env_common" ]; then
-
source "${HOME}/.env_common"
-
else
-
echo ".env_common not found"
-
exit 1
-
fi
-
-
TILDEGIT_URL="https://tildegit.org"
-
TILDEGIT_CLONE_URL="git@tildegit.org:hyperreal"
-
BACKUP_DIR="/naspool/tildegit-backup"
-
-
curl -s -k \
-
-u "hyperreal:${GITEA_TOKEN}" \
-
"${TILDEGIT_URL}/api/v1/user/repos?limit=100&page=1" |
-
jq '.[].name | select(.!="keyoxide_proof")' |
-
tr -d '"' |
-
tee "${BACKUP_DIR}/repos.txt"
-
-
while read -r line; do
-
if [ -d "${BACKUP_DIR}/${line}" ]; then
-
cd "${BACKUP_DIR}/${line}"
-
git pull
-
else
-
cd "${BACKUP_DIR}"
-
git clone "${TILDEGIT_CLONE_URL}/${line}.git"
-
fi
-
sleep 30
-
done <"${BACKUP_DIR}/repos.txt"
-
-
# vim: ts=4 sw=4 sts=4 ai et ft=bash