Revert to last night.
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 19s

This commit is contained in:
Your Name
2025-05-10 19:44:28 +12:00
parent 5d42db7331
commit 330bdf9941
13 changed files with 547 additions and 228 deletions

View File

@ -1,9 +1,13 @@
#!/bin/bash
# This script contains the common code for the autocommands.
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
MYID=$(id -u)
MYGRP=$(id -g)
BACKUP_TEMP_PATH="$TEMP_DIR/backup"
_autocommandrun_volume() {
local command="$1"
local volume_name="$2"
@ -108,8 +112,7 @@ _autocommandparse() {
local command="$1"
shift
local backup_temp_path="$1"
shift
echo "autocommandparse: command=$command"
# Extract the backup file and temp path (last two arguments)
local args=("$@")
@ -129,7 +132,7 @@ _autocommandparse() {
# create backup folder unique to key/value.
local bfolder=$(echo "${key}_${value}" | tr -cd '[:alnum:]_-')
local targetpath="${backup_temp_path}/${bfolder}"
local targetpath="${BACKUP_TEMP_PATH}/${bfolder}"
mkdir -p ${targetpath}
# Key must be one of volume, path or file
@ -152,57 +155,31 @@ _autocommandparse() {
autocreate() {
_check_required_env_vars "TEMP_DIR"
local create_temp_path="$TEMP_DIR/create"
mkdir -p "$create_temp_path"
_autocommandparse create "$create_temp_path" "$@"
rm -rf "$create_temp_path"
_autocommandparse create "$@"
}
autonuke() {
_check_required_env_vars "TEMP_DIR"
local nuke_temp_path="$TEMP_DIR/nuke"
mkdir -p "$nuke_temp_path"
_autocommandparse nuke "$nuke_temp_path" "$@"
rm -rf "$nuke_temp_path"
_autocommandparse nuke "$@"
}
autobackup() {
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
local backup_temp_path="$TEMP_DIR/backup"
mkdir -p "$BACKUP_TEMP_PATH"
echo "_autocommandparse [backup] [$@]"
_autocommandparse backup "$@"
mkdir -p "$backup_temp_path"
echo "_autocommandparse [backup] [$backup_temp_path] [$@]"
# backup the files into the temp path.
_autocommandparse backup "$backup_temp_path" "$@"
# create the backup file.
tar zcvf "$BACKUP_FILE" -C "$backup_temp_path" .
rm -rf "$backup_temp_path"
tar zcvf "$BACKUP_FILE" -C "$BACKUP_TEMP_PATH" .
}
autorestore() {
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
local backup_temp_path="$TEMP_DIR/restore"
echo "_autocommandparse [restore] [$@]"
echo "_autocommandparse [restore] [$backup_temp_path] [$@]"
mkdir -p "$BACKUP_TEMP_PATH"
tar zxvf "$BACKUP_FILE" -C "$BACKUP_TEMP_PATH" --strip-components=1
mkdir -p "$backup_temp_path"
# extract the backup file into the temp path.
tar zxvf "$BACKUP_FILE" -C "$backup_temp_path" --strip-components=1
# restore the files from the temp path.
_autocommandparse restore "$backup_temp_path" "$@"
rm -rf "$backup_temp_path"
_autocommandparse restore "$@"
}