Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup #1175

Merged
merged 3 commits into from
Oct 23, 2023
Merged

Backup #1175

Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion runs/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand All @@ -51,6 +56,7 @@ fi
--file="$BACKUPFILE" \
--directory="$OPENWBBASEDIR/ramdisk/" \
"GIT_BRANCH" "GIT_HASH"

echo "calculating checksums"
# openwb directory
find "$OPENWBBASEDIR" \( \
Expand All @@ -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"
Expand All @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions runs/prepare_restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions runs/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down