mirror of
https://github.com/edv-pi/pbs-client-docker.git
synced 2025-04-20 07:52:56 +02:00
readd mount script to fit to changes from upstream repo
This commit is contained in:
parent
c69aa29b60
commit
3098433c12
73
docker/src/helper_scripts/mount-backup
Normal file
73
docker/src/helper_scripts/mount-backup
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#!/usr/bin/with-contenv bash
|
||||||
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
source /etc/s6-overlay/s6-rc.d/setup_check/run_include
|
||||||
|
|
||||||
|
# We need to build this command in case namespaces are in use.
|
||||||
|
MOUNTCMD="proxmox-backup-client mount"
|
||||||
|
LISTCMD="proxmox-backup-client snapshot list"
|
||||||
|
if [ -n "$PBS_DATASTORE_NS" ]; then
|
||||||
|
LISTCMD+=" --ns ${PBS_DATASTORE_NS}"
|
||||||
|
MOUNTCMD+=" --ns ${PBS_DATASTORE_NS}"
|
||||||
|
fi
|
||||||
|
LISTCMD+=" --output-format json"
|
||||||
|
|
||||||
|
data=$(${LISTCMD})
|
||||||
|
host_name=$(hostname)
|
||||||
|
|
||||||
|
# Backups in einer nummerierten Liste ausgeben
|
||||||
|
options=$(echo "$data" | jq -r --arg host "$host_name" '
|
||||||
|
.[] |
|
||||||
|
select(.["backup-id"] == $host) |
|
||||||
|
"\(.["backup-type"])/\($host)/\(.["backup-time"] | tonumber | strftime("%Y-%m-%dT%H:%M:%SZ"))"')
|
||||||
|
|
||||||
|
# Array erstellen und anzeigen
|
||||||
|
echo "Verfügbare Backups:"
|
||||||
|
IFS=$'\n' read -d '' -r -a backups <<< "$options"
|
||||||
|
for i in "${!backups[@]}"; do
|
||||||
|
echo "$((i + 1)). ${backups[i]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Benutzereingabe für die Auswahl
|
||||||
|
read -p "Wählen Sie ein Backup aus (Nummer eingeben): " selection
|
||||||
|
|
||||||
|
# Überprüfen, ob die Eingabe gültig ist
|
||||||
|
if [[ "$selection" -ge 1 && "$selection" -le "${#backups[@]}" ]]; then
|
||||||
|
selected_backup="${backups[$((selection - 1))]}"
|
||||||
|
MOUNTCMD+=" $selected_backup"
|
||||||
|
echo "Ausgewähltes Backup: $selected_backup"
|
||||||
|
|
||||||
|
# Dateien des ausgewählten Backups abrufen
|
||||||
|
backup_index=$((selection - 1))
|
||||||
|
files=$(echo "$data" | jq -r --argjson index "$backup_index" '
|
||||||
|
.[$index].files[].filename | select(test("\\.pxar.didx$|\\.mpxar.didx$"))')
|
||||||
|
|
||||||
|
# Dateien in einer nummerierten Liste ausgeben
|
||||||
|
echo "Verfügbare Dateien:"
|
||||||
|
IFS=$'\n' read -d '' -r -a file_list <<< "$files"
|
||||||
|
for i in "${!file_list[@]}"; do
|
||||||
|
echo "$((i + 1)). ${file_list[i]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Benutzereingabe für die Dateiauswahl
|
||||||
|
read -p "Wählen Sie eine Datei aus (Nummer eingeben): " file_selection
|
||||||
|
|
||||||
|
# Überprüfen, ob die Eingabe gültig ist
|
||||||
|
if [[ "$file_selection" -ge 1 && "$file_selection" -le "${#file_list[@]}" ]]; then
|
||||||
|
selected_file="${file_list[$((file_selection - 1))]}"
|
||||||
|
MOUNTCMD+=" $selected_file"
|
||||||
|
echo "Ausgewählte Datei: $selected_file"
|
||||||
|
echo "DEBUG: $MOUNTCMD"
|
||||||
|
MOUNTCMD+=" /restore"
|
||||||
|
$(${MOUNTCMD})
|
||||||
|
echo "Dont forget to unmount when finished (just umount /path/on/the/host i.e. /restore)"
|
||||||
|
else
|
||||||
|
echo "Ungültige Auswahl. Abbruch."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Ungültige Auswahl. Abbruch."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user