Update source/agent-remote/datacommands_v2.sh
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 31s
Build-Test-Publish / build (linux/arm64) (push) Successful in 56s

This commit is contained in:
Your Name
2025-08-30 18:04:20 +12:00
parent fedec545e8
commit d04beefb42

View File

@@ -281,7 +281,7 @@ backup_volume() {
restore_volume() {
local label="$1"
local volume_name="$2"
local backup_folder="$3"
local backup_folder="$TEMP_DIR/backup"
echo "[restore_volume] label=$label volume=$volume_name backup_folder=$backup_folder"
@@ -315,98 +315,98 @@ restore_volume() {
fi
}
# # ============================================================================
# # MAIN BACKUP/RESTORE ORCHESTRATION
# # ============================================================================
# ============================================================================
# MAIN BACKUP/RESTORE ORCHESTRATION
# ============================================================================
# # Process multiple items for backup
# # Usage: backup_items <backup_file> <temp_dir> type1:label1:location1 type2:label2:location2 ...
# backup_items() {
# local backup_file="$1"
# local temp_dir="$2"
# shift 2
# Process multiple items for backup
# Usage: backup_items type1:label1:location1 type2:label2:location2 ...
backup_items() {
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
local backup_file="${BACKUP_FILE}"
local temp_dir="${TEMP_DIR}"
# local backup_temp_path="${temp_dir}/backup"
# mkdir -p "$backup_temp_path"
local backup_temp_path="${temp_dir}/backup"
mkdir -p "$backup_temp_path"
# echo "Starting backup to ${backup_file}"
echo "Starting backup to ${backup_file}"
# # Process each item
# for item in "$@"; do
# IFS=':' read -r type label location <<< "$item"
# Process each item
for item in "$@"; do
IFS=':' read -r type label location <<< "$item"
# case "$type" in
# file)
# backup_file "$label" "$location" "$backup_temp_path"
# ;;
# path)
# backup_path "$label" "$location" "$backup_temp_path"
# ;;
# volume)
# backup_volume "$label" "$location" "$backup_temp_path"
# ;;
# *)
# echo "Unknown type: $type (must be file, path, or volume)"
# ;;
# esac
# done
case "$type" in
file)
backup_file "$label" "$location" "$backup_temp_path"
;;
path)
backup_path "$label" "$location" "$backup_temp_path"
;;
volume)
backup_volume "$label" "$location" "$backup_temp_path"
;;
*)
echo "Unknown type: $type (must be file, path, or volume)"
;;
esac
done
# # Create final backup archive
# echo "Creating backup archive ${backup_file}"
# tar -czf "$backup_file" -C "$backup_temp_path" .
# Create final backup archive
echo "Creating backup archive ${backup_file}"
tar -czf "$backup_file" -C "$backup_temp_path" .
# # Clean up temp directory
# rm -rf "$backup_temp_path"
# Clean up temp directory
rm -rf "$backup_temp_path"
# echo "Backup completed successfully"
# }
echo "Backup completed successfully"
}
# # Process multiple items for restore
# # Usage: restore_items <backup_file> <temp_dir> type1:label1:location1 type2:label2:location2 ...
# restore_items() {
# local backup_file="$1"
# local temp_dir="$2"
# shift 2
# Process multiple items for restore
# Usage: restore_items type1:label1:location1 type2:label2:location2 ...
restore_items() {
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
local backup_file="${BACKUP_FILE}"
local temp_dir="${TEMP_DIR}"
# if [ ! -f "$backup_file" ]; then
# echo "Backup file $backup_file not found"
# return 1
# fi
if [ ! -f "$backup_file" ]; then
echo "Backup file $backup_file not found"
return 1
fi
# local restore_temp_path="${temp_dir}/restore"
# mkdir -p "$restore_temp_path"
local restore_temp_path="${temp_dir}/restore"
mkdir -p "$restore_temp_path"
# echo "Starting restore from ${backup_file}"
echo "Starting restore from ${backup_file}"
# # Extract backup archive
# echo "Extracting backup archive"
# tar -xzf "$backup_file" -C "$restore_temp_path"
# Extract backup archive
echo "Extracting backup archive"
tar -xzf "$backup_file" -C "$restore_temp_path"
# # Process each item
# for item in "$@"; do
# IFS=':' read -r type label location <<< "$item"
# Process each item
for item in "$@"; do
IFS=':' read -r type label location <<< "$item"
# case "$type" in
# file)
# restore_file "$label" "$location" "$restore_temp_path"
# ;;
# path)
# restore_path "$label" "$location" "$restore_temp_path"
# ;;
# volume)
# restore_volume "$label" "$location" "$restore_temp_path"
# ;;
# *)
# echo "Unknown type: $type (must be file, path, or volume)"
# ;;
# esac
# done
case "$type" in
file)
restore_file "$label" "$location" "$restore_temp_path"
;;
path)
restore_path "$label" "$location" "$restore_temp_path"
;;
volume)
restore_volume "$label" "$location" "$restore_temp_path"
;;
*)
echo "Unknown type: $type (must be file, path, or volume)"
;;
esac
done
# # Clean up temp directory
# rm -rf "$restore_temp_path"
# Clean up temp directory
rm -rf "$restore_temp_path"
# echo "Restore completed successfully"
# }
echo "Restore completed successfully"
}
# # ============================================================================
# # LEGACY COMPATIBILITY WRAPPER (can be removed once migration is complete)