From ae9401dbea2467a6d5c4173ced870c628b451cab Mon Sep 17 00:00:00 2001 From: MrTylerjet Date: Mon, 15 Jul 2024 21:58:49 -0600 Subject: [PATCH] fix space in paramater check for --restore in install.sh, add moonraker_db_backup variable and functions for running moonraker backup/restore scripts - #105. --- install.sh | 2 +- script.sh | 6 ++++++ utils/restore_data.sh | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index af4bb62..548dee6 100755 --- a/install.sh +++ b/install.sh @@ -456,7 +456,7 @@ install_cron() { if [ "$1" == "check_updates" ]; then check_updates -elif [ "$1" == "--restore"]; then +elif [ "$1" == "--restore" ]; then exec $parent_path/utils/restore_data.sh else main diff --git a/script.sh b/script.sh index 3303dab..f2af623 100755 --- a/script.sh +++ b/script.sh @@ -22,6 +22,7 @@ echo -e "\r\033[K${G}●${NC} Checking for installed dependencies ${G}Done!${NC} backup_folder="config_backup" backup_path="$HOME/$backup_folder" backup_restore_data="$HOME"/klipper-backup-restore +moonraker_db_backups=${moonraker_db_backups:-false} theme_path="$HOME"/printer_data/config/.theme allow_empty_commits=${allow_empty_commits:-true} git_protocol=${git_protocol:-"https"} @@ -149,6 +150,11 @@ done 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 +fi + # utilize gits native exclusion file .gitignore to add files that should not be uploaded to remote. # Loop through exclude array and add each element to the end of .gitignore for i in ${exclude[@]}; do diff --git a/utils/restore_data.sh b/utils/restore_data.sh index b42ebc7..13c5793 100755 --- a/utils/restore_data.sh +++ b/utils/restore_data.sh @@ -39,6 +39,7 @@ main() { source $temprestore sudo systemctl stop klipper.service moonraker.service restoreBackupFiles + restoreMoonrakerDB copyTheme cleanup } @@ -174,6 +175,7 @@ tempfolder() { } copyRestoreConfig() { + echo -e "Restore config token, username, repo, branch name" sed -i "s/^github_token=.*/github_token=$ghtoken/" $temprestore sed -i "s/^github_username=.*/github_username=$ghuser/" $temprestore sed -i "s/^github_repository=.*/github_repository=$ghrepo/" $temprestore @@ -182,6 +184,7 @@ copyRestoreConfig() { } restoreBackupFiles() { + echo -e "Restore Backupt Files" for path in "${backupPaths[@]}"; do echo $path for file in $path; do @@ -191,7 +194,13 @@ restoreBackupFiles() { done } +restoreMoonrakerDB() { + echo -e "Restore Moonraker Database" + bash "$HOME"/moonraker/scripts/restore-database.sh -i "$tempfolder"/database.backup +} + copyTheme() { + echo -e "Restore Theme" if [[ $theme_url ]]; then cd "$HOME"/printer_data/config/ git clone $theme_url .theme