Skip to content

Commit

Permalink
fix space in paramater check for --restore in install.sh, add moonrak…
Browse files Browse the repository at this point in the history
…er_db_backup variable and functions for running moonraker backup/restore scripts - #105.
  • Loading branch information
Tylerjet committed Jul 16, 2024
1 parent ed1cec1 commit ae9401d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions utils/restore_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ main() {
source $temprestore
sudo systemctl stop klipper.service moonraker.service
restoreBackupFiles
restoreMoonrakerDB
copyTheme
cleanup
}
Expand Down Expand Up @@ -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
Expand All @@ -182,6 +184,7 @@ copyRestoreConfig() {
}

restoreBackupFiles() {
echo -e "Restore Backupt Files"
for path in "${backupPaths[@]}"; do
echo $path
for file in $path; do
Expand All @@ -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
Expand Down

0 comments on commit ae9401d

Please sign in to comment.