Skip to content

Commit

Permalink
#105 - use the proper moonraker api method instead of deprecated method
Browse files Browse the repository at this point in the history
  • Loading branch information
Tylerjet committed Jul 16, 2024
1 parent 1504707 commit a297411
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 9 additions & 1 deletion script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ cp "$parent_path"/.gitignore "$backup_path/.gitignore"

if [ $moonraker_db_backups ]; then
echo -e "Backup Moonraker DB"
bash "$HOME"/moonraker/scripts/backup-database.sh -o "$backup_path"/database.backup
MOONRAKER_URL="http://localhost:7125"
data='{ "filename": "moonraker-db-klipperbackup.db" }'
if curl -X POST "$MOONRAKER_URL/server/database/backup" \
-H "Content-Type: application/json" \
-d "$data" >/dev/null 2>&1; then
cp "$HOME"/printer_data/backup/database/moonraker-db-klipperbackup.db "$backup_path"/moonraker-db-klipperbackup.db
else
echo -e "Database Backup Failed - Is the printer printing?"
fi
fi

# utilize gits native exclusion file .gitignore to add files that should not be uploaded to remote.
Expand Down
9 changes: 7 additions & 2 deletions utils/restore_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,13 @@ restoreBackupFiles() {

restoreMoonrakerDB() {
echo -e "Restore Moonraker Database"
if [ -f "$tempfolder/database.backup" ]; then
bash "$HOME"/moonraker/scripts/restore-database.sh -i "$tempfolder"/database.backup
if [ -f "$tempfolder/moonraker-db-klipperbackup.db" ]; then
cp $tempfolder/moonraker-db-klipperbackup.db "$HOME/printer_data/backup/database/moonraker-db-klipperbackup.db"
MOONRAKER_URL="http://localhost:7125"
data='{ "filename": "moonraker-db-klipperbackup.db" }'
curl -X POST "$MOONRAKER_URL/server/database/restore" \
-H "Content-Type: application/json" \
-d "$data" >/dev/null 2>&1
fi
}

Expand Down

0 comments on commit a297411

Please sign in to comment.