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

This commit is contained in:
Your Name
2025-08-31 11:30:00 +12:00
parent dfe50b7fa9
commit fc20c62671

View File

@@ -73,13 +73,13 @@ backup_file() {
# Store metadata about the file
echo "${filepath}" > "${target_dir}/original_path.txt"
# Copy the file
# Copy the file - save as the label name, not original filename
docker run --rm \
-v "${file_parent}":/source \
-v "${target_dir}":/backup \
debian bash -c "cp /source/${file_name} /backup/${file_name} && chown -R $MYID:$MYGRP /backup"
debian bash -c "cp /source/${file_name} /backup/${label}.data && chown -R $MYID:$MYGRP /backup"
echo "File ${filepath} backed up successfully"
echo "File ${filepath} backed up successfully as ${label}.data"
else
echo "File ${filepath} does not exist - nothing to backup"
fi
@@ -99,10 +99,8 @@ restore_file() {
return 1
fi
local file_name
file_name=$(basename "${filepath}")
if [ -f "${source_dir}/${file_name}" ]; then
# File is backed up as ${label}.data, not original filename
if [ -f "${source_dir}/${label}.data" ]; then
# Ensure parent directory exists
local file_parent
file_parent=$(dirname "${filepath}")
@@ -111,11 +109,11 @@ restore_file() {
# Remove existing file if present
rm -f "${filepath}"
# Copy from backup
cp "${source_dir}/${file_name}" "${filepath}"
echo "File ${filepath} restored successfully"
# Copy from backup - restore from label.data to target filepath
cp "${source_dir}/${label}.data" "${filepath}"
echo "File ${filepath} restored successfully from ${label}.data"
else
echo "Backup file ${source_dir}/${file_name} not found"
echo "Backup file ${source_dir}/${label}.data not found"
return 1
fi
}