Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 9 additions & 3 deletions packages/helpermodules/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,15 @@ def systemFetchVersions(self, connection_id: str, payload: dict) -> None:
def createBackup(self, connection_id: str, payload: dict) -> None:
pub_user_message(payload, connection_id, "Sicherung wird erstellt...", MessageType.INFO)
parent_file = Path(__file__).resolve().parents[2]
result = run_command(
[str(parent_file / "runs" / "backup.sh"),
"1" if "use_extended_filename" in payload["data"] and payload["data"]["use_extended_filename"] else "0"])
try:
result = run_command([
str(parent_file / "runs" / "backup.sh"),
"1" if "use_extended_filename" in payload["data"] and payload["data"]["use_extended_filename"] else "0"
], process_exception=False)
except subprocess.CalledProcessError:
pub_user_message(payload, connection_id,
"Fehler beim Erstellen der Sicherung. Bitte Logdatei prüfen.", MessageType.ERROR)
return
file_name = result.rstrip('\n')
file_link = "/openWB/data/backup/" + file_name
pub_user_message(payload, connection_id,
Expand Down
2 changes: 1 addition & 1 deletion packages/helpermodules/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def create_backup_and_send_to_cloud(self):

def create_backup(self) -> str:
try:
result = run_command([str(self._get_parent_file() / "runs" / "backup.sh"), "1"])
result = run_command([str(self._get_parent_file() / "runs" / "backup.sh"), "1"], process_exception=False)
file_name = result.rstrip('\n')
return file_name
except subprocess.CalledProcessError as e:
Expand Down
23 changes: 19 additions & 4 deletions runs/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,19 @@ force_mosquitto_write() {

collect_git_info() {
echo "collecting git information"
git branch --no-color --show-current >"$TEMPDIR/GIT_BRANCH"
git log --pretty='format:%H' -n1 >"$TEMPDIR/GIT_HASH"
echo "branch: $(<"$TEMPDIR/GIT_BRANCH") commit-hash: $(<"$TEMPDIR/GIT_HASH")"
if git branch --no-color --show-current >"$TEMPDIR/GIT_BRANCH"; then
echo "current branch: $(<"$TEMPDIR/GIT_BRANCH")"
else
echo "failed to collect git branch info"
return 1
fi
if git log --pretty='format:%H' -n1 >"$TEMPDIR/GIT_HASH"; then
echo "current commit hash: $(<"$TEMPDIR/GIT_HASH")"
else
echo "failed to collect git commit hash"
return 1
fi
return 0
}

create_archive() {
Expand Down Expand Up @@ -277,7 +287,12 @@ create_archive() {
generate_filename
log_environment
remove_old_backups
collect_git_info
if collect_git_info; then
echo "git information collected successfully"
else
echo "error: failed to collect git information"
exit 1
fi
force_mosquitto_write
create_archive
echo "backup finished"
Expand Down