A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys, Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun VPN routing, and a web dashboard to manage it all. Free & open forever to self-host; optional paid hosted services fund it. See PROMISE.md. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
73 lines
1.8 KiB
Bash
73 lines
1.8 KiB
Bash
#!/bin/bash
|
|
|
|
resticInitLocation()
|
|
{
|
|
local idx="$1"
|
|
|
|
if ! resticLocationEnabled "$idx"; then
|
|
isNotice "Location $(resticLocationName "$idx") disabled — skipping init"
|
|
return 0
|
|
fi
|
|
|
|
resticEnvExport "$idx" || return 1
|
|
|
|
if [[ "$(resticLocationType "$idx")" == "local" ]]; then
|
|
sudo mkdir -p "$RESTIC_REPOSITORY"
|
|
sudo chown -R "$docker_install_user":"$docker_install_user" "$RESTIC_REPOSITORY"
|
|
fi
|
|
|
|
if sudo -E -u "$docker_install_user" restic snapshots --json --no-lock >/dev/null 2>&1; then
|
|
isNotice "$(resticLocationName "$idx") already initialized at $RESTIC_REPOSITORY"
|
|
resticEnvUnset
|
|
return 0
|
|
fi
|
|
|
|
isNotice "Initializing $(resticLocationName "$idx") at $RESTIC_REPOSITORY"
|
|
if sudo -E -u "$docker_install_user" restic init; then
|
|
isSuccessful "$(resticLocationName "$idx") initialized"
|
|
else
|
|
isError "Failed to initialize $(resticLocationName "$idx")"
|
|
resticEnvUnset
|
|
return 1
|
|
fi
|
|
|
|
resticEnvUnset
|
|
}
|
|
|
|
resticInitAllLocations()
|
|
{
|
|
isHeader "Backup Location Initialization"
|
|
local idx
|
|
while IFS= read -r idx; do
|
|
[[ -z "$idx" ]] && continue
|
|
resticInitLocation "$idx"
|
|
done < <(resticEnabledLocations)
|
|
}
|
|
|
|
resticEnsureLocationReady()
|
|
{
|
|
local idx="$1"
|
|
[[ -z "$idx" ]] && return 1
|
|
|
|
if ! resticLocationEnabled "$idx"; then
|
|
return 1
|
|
fi
|
|
|
|
if ! command -v restic >/dev/null 2>&1; then
|
|
resticInstall || return 1
|
|
fi
|
|
resticInitLocation "$idx"
|
|
}
|
|
|
|
resticEnsureAllLocationsReady()
|
|
{
|
|
if ! command -v restic >/dev/null 2>&1; then
|
|
resticInstall || return 1
|
|
fi
|
|
local idx
|
|
while IFS= read -r idx; do
|
|
[[ -z "$idx" ]] && continue
|
|
resticEnsureLocationReady "$idx"
|
|
done < <(resticEnabledLocations)
|
|
}
|