From 2ecb98f36599d605c5d7be3dde6063cb1f1b75af Mon Sep 17 00:00:00 2001 From: Lutz Bender Date: Tue, 17 Oct 2023 12:02:42 +0200 Subject: [PATCH 1/3] add configuration to backup --- runs/backup.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runs/backup.sh b/runs/backup.sh index 6ebbd975a5..a5f3e06ef7 100755 --- a/runs/backup.sh +++ b/runs/backup.sh @@ -38,6 +38,11 @@ fi --exclude "__pycache__" \ --exclude "$OPENWBDIRNAME/.pytest_cache" \ "$OPENWBDIRNAME" + echo "adding configuration file" + sudo tar --verbose --append \ + --file="$BACKUPFILE" \ + --directory="/home/openwb/" \ + "configuration.json" echo "adding mosquitto files" sudo tar --verbose --append \ --file="$BACKUPFILE" \ @@ -51,6 +56,7 @@ fi --file="$BACKUPFILE" \ --directory="$OPENWBBASEDIR/ramdisk/" \ "GIT_BRANCH" "GIT_HASH" + echo "calculating checksums" # openwb directory find "$OPENWBBASEDIR" \( \ @@ -63,6 +69,8 @@ fi -name "backup.log" \ \) -prune -o \ -type f -print0 | xargs -0 sha256sum | sed -n "s|$TARBASEDIR/||p" >"$OPENWBBASEDIR/ramdisk/SHA256SUM" + # configuration file + echo -n "/home/openwb/configuration.json" | xargs -0 sha256sum | sed -n "s|/home/openwb/||p" >>"$OPENWBBASEDIR/ramdisk/SHA256SUM" # git info files find "$OPENWBBASEDIR/ramdisk/GIT_"* \ -type f -print0 | xargs -0 sha256sum | sed -n "s|$OPENWBBASEDIR/ramdisk/||p" >>"$OPENWBBASEDIR/ramdisk/SHA256SUM" @@ -73,10 +81,11 @@ fi --file="$BACKUPFILE" \ --directory="$OPENWBBASEDIR/ramdisk/" \ "SHA256SUM" + # cleanup echo "removing temporary files" rm -v "$OPENWBBASEDIR/ramdisk/GIT_BRANCH" "$OPENWBBASEDIR/ramdisk/GIT_HASH" "$OPENWBBASEDIR/ramdisk/SHA256SUM" - tar --verbose --append \ + tar --append \ --file="$BACKUPFILE" \ --directory="$OPENWBBASEDIR/data/log/" \ "backup.log" From 748bfbc98f8505a965404e23c1a5c594e2ede53f Mon Sep 17 00:00:00 2001 From: Lutz Bender Date: Tue, 17 Oct 2023 12:20:40 +0200 Subject: [PATCH 2/3] restore configuration --- runs/prepare_restore.sh | 3 +++ runs/restore.sh | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/runs/prepare_restore.sh b/runs/prepare_restore.sh index 966a2b6e95..86f8c2513c 100755 --- a/runs/prepare_restore.sh +++ b/runs/prepare_restore.sh @@ -31,6 +31,9 @@ declare resultStatus resultMessage="Das Archiv ist nicht vollständig!" resultStatus=1 else + if [[ ! -f "$WORKING_DIR/configuration.json" ]]; then + echo "configuration missing; continue anyway" + fi if ! (cd "$WORKING_DIR" && sudo sha256sum --quiet --check "SHA256SUM"); then resultMessage="Einige Dateien wurden gelöscht oder bearbeitet!" resultStatus=1 diff --git a/runs/restore.sh b/runs/restore.sh index e150d770ab..d030f94055 100755 --- a/runs/restore.sh +++ b/runs/restore.sh @@ -48,6 +48,11 @@ LOG_FILE="$OPENWB_BASE_DIR/data/log/restore.log" echo "Step 4: restore contents of backup" # we use cp not mv because of not empty directories in destination sudo cp -v -p -r "${WORKING_DIR}/openWB/." "${OPENWB_BASE_DIR}/" + if [[ -f "$WORKING_DIR/configuration.json" ]]; then + sudo mv -v -f "${WORKING_DIR}/configuration.json" "/home/openwb/" + else + echo "Backup does not contain configuration. Skipping restore." + fi echo "****************************************" echo "Step 5: restore mosquitto db" if [[ -f "${WORKING_DIR}/mosquitto/mosquitto.db" ]]; then From c5645253655df2b16cf322d61701a9300e534757 Mon Sep 17 00:00:00 2001 From: Lutz Bender Date: Mon, 23 Oct 2023 11:22:48 +0200 Subject: [PATCH 3/3] remove colons in extended filename --- runs/backup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runs/backup.sh b/runs/backup.sh index a5f3e06ef7..cf6b94f9fd 100755 --- a/runs/backup.sh +++ b/runs/backup.sh @@ -8,7 +8,9 @@ LOGFILE="$OPENWBBASEDIR/data/log/backup.log" useExtendedFilename=$1 if ((useExtendedFilename == 1)); then - FILENAME="openWB_backup_$(date +"%Y-%m-%d_%H:%M:%S").tar" + # only use characters supported in most OS! + # for Win see https://learn.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-shares--directories--files--and-metadata + FILENAME="openWB_backup_$(date +"%Y-%m-%d_%H-%M-%S").tar" else FILENAME="backup.tar" fi