1
0

pkgs/clerie-backup: Support sftp backend for restic

This commit is contained in:
2025-11-16 19:38:50 +01:00
parent 1ab3ae3769
commit 971fb88d97
2 changed files with 29 additions and 13 deletions

View File

@@ -45,30 +45,39 @@ if [[ ! -f "${CONFIG_DIR}/auth_username" ]]; then
echo "File ${CONFIG_DIR}/auth_username not found"
ISSUE_EXIST=1
fi
if [[ ! -f "${CONFIG_DIR}/auth_password" ]]; then
echo "File ${CONFIG_DIR}/auth_password not found"
ISSUE_EXIST=1
fi
if [[ -n "${ISSUE_EXIST}" ]]; then
exit 1
fi
RESTIC_PASSWORD_FILE="${CONFIG_DIR}/repo_password"
export RESTIC_PASSWORD_FILE
RESTIC_REPOSITORY="rest:$(cat "${CONFIG_DIR}/repo_url")"
REPO_URL="$(cat "${CONFIG_DIR}/repo_url")"
if [[ "${REPO_URL}" == http* ]]; then
RESTIC_REPOSITORY="rest:${REPO_URL}"
else
RESTIC_REPOSITORY="${REPO_URL}"
fi
export RESTIC_REPOSITORY
RESTIC_REST_USERNAME="$(cat "${CONFIG_DIR}/auth_username")"
export RESTIC_REST_USERNAME
RESTIC_REST_PASSWORD="$(cat "${CONFIG_DIR}/auth_password")"
export RESTIC_REST_PASSWORD
if [[ -e "${CONFIG_DIR}/auth_password" ]]; then
RESTIC_REST_PASSWORD="$(cat "${CONFIG_DIR}/auth_password")"
export RESTIC_REST_PASSWORD
fi
RESTIC_PROGRESS_FPS="0.1"
export RESTIC_PROGRESS_FPS
RESTIC_CACHE_DIR="/var/cache/restic"
export RESTIC_CACHE_DIR
EXTRA_OPTIONS=()
if [[ -e "${CONFIG_DIR}/ssh_key" ]]; then
EXTRA_OPTIONS+=("-o" "sftp.args='-o IdentityFile=${CONFIG_DIR}/ssh_key'")
fi
case "${ACTION}" in
restic)
restic "$@"
restic "${EXTRA_OPTIONS[@]}" "$@"
;;
backup)
ISSUE_EXIST=
@@ -84,9 +93,9 @@ backup)
exit 1
fi
restic snapshots --latest 1 || restic init
restic "${EXTRA_OPTIONS[@]}" snapshots --latest 1 || restic "${EXTRA_OPTIONS[@]}" init
restic backup --exclude-file "${CONFIG_DIR}/excludes" --files-from "${CONFIG_DIR}/files"
restic "${EXTRA_OPTIONS[@]}" backup --exclude-file "${CONFIG_DIR}/excludes" --files-from "${CONFIG_DIR}/files"
;;
*)
echo "Unsupported ACTION: ${ACTION}"