backup menu
This commit is contained in:
@@ -69,7 +69,7 @@ new_instance () {
|
|||||||
INSTALL=2
|
INSTALL=2
|
||||||
DAEMONPATH=$BUDEFAULT
|
DAEMONPATH=$BUDEFAULT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Enter the name for new printer/instance (no spaces):"
|
echo "Enter the name for new printer/instance (no spaces):"
|
||||||
read INSTANCE
|
read INSTANCE
|
||||||
if [ -z "$INSTANCE" ]; then
|
if [ -z "$INSTANCE" ]; then
|
||||||
@@ -844,7 +844,7 @@ firstrun() {
|
|||||||
$OCTOEXEC config set server.firstRun false --bool | log
|
$OCTOEXEC config set server.firstRun false --bool | log
|
||||||
$OCTOEXEC config set server.seenWizards.backup null | log
|
$OCTOEXEC config set server.seenWizards.backup null | log
|
||||||
$OCTOEXEC config set server.seenWizards.corewizard 4 --int | log
|
$OCTOEXEC config set server.seenWizards.corewizard 4 --int | log
|
||||||
|
|
||||||
if prompt_confirm "Enable online connectivity check?"; then
|
if prompt_confirm "Enable online connectivity check?"; then
|
||||||
$OCTOEXEC config set server.onlineCheck.enabled true --bool
|
$OCTOEXEC config set server.onlineCheck.enabled true --bool
|
||||||
else
|
else
|
||||||
@@ -922,6 +922,22 @@ remove_everything() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
create_menu() {
|
||||||
|
PS3='Select instance to backup: '
|
||||||
|
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:alnum:]]*\) .*/\1/p')
|
||||||
|
options+=("Quit")
|
||||||
|
select opt in "${options[@]}"
|
||||||
|
do
|
||||||
|
if [ "$opt" == Quit ] || [ "$opt" == generic ]; then
|
||||||
|
main_menu
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Selected instance to backup: $opt" | log
|
||||||
|
back_up $opt
|
||||||
|
done
|
||||||
|
main_menu
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
restart_all() {
|
restart_all() {
|
||||||
get_settings
|
get_settings
|
||||||
@@ -931,7 +947,7 @@ restart_all() {
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "Trying to restart instance $instance"
|
echo "Trying to restart instance $instance"
|
||||||
systemctl restart $instance
|
systemctl restart $instance
|
||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@@ -940,10 +956,20 @@ back_up() {
|
|||||||
INSTANCE=$1
|
INSTANCE=$1
|
||||||
echo "Creating backup of $INSTANCE...."
|
echo "Creating backup of $INSTANCE...."
|
||||||
d=$(date '+%Y-%m-%d')
|
d=$(date '+%Y-%m-%d')
|
||||||
sudo -p $user tar -czf ${INSTANCE}_${d}_backup.tar.gz /home/$user/.$INSTANCE
|
sudo -p $user tar -czf ${INSTANCE}_${d}_backup.tar.gz -C /home/$user/ .${INSTANCE}
|
||||||
echo "Tarred and gzipped backup created in /home/$user"
|
echo "Tarred and gzipped backup created in /home/$user"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restore() {
|
||||||
|
INSTANCE=$1
|
||||||
|
TAR=$2
|
||||||
|
echo "Restoring backup of $INSTANCE...."
|
||||||
|
systemctl stop $INSTANCE
|
||||||
|
sudo -p $user tar -xvf $TAR
|
||||||
|
systemctl start $INSTANCE
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
back_up_all() {
|
back_up_all() {
|
||||||
get_settings
|
get_settings
|
||||||
readarray -t instances < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:alnum:]]*\) .*/\1/p')
|
readarray -t instances < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:alnum:]]*\) .*/\1/p')
|
||||||
@@ -954,8 +980,9 @@ back_up_all() {
|
|||||||
echo $instance
|
echo $instance
|
||||||
back_up $instance
|
back_up $instance
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu() {
|
main_menu() {
|
||||||
#reset
|
#reset
|
||||||
UDEV=''
|
UDEV=''
|
||||||
@@ -966,7 +993,7 @@ main_menu() {
|
|||||||
INSTALL=''
|
INSTALL=''
|
||||||
PS3='Select operation: '
|
PS3='Select operation: '
|
||||||
if [ -f "/etc/octoprint_instances" ]; then
|
if [ -f "/etc/octoprint_instances" ]; then
|
||||||
options=("New instance" "Delete instance" "Add Camera" "USB port testing" "Quit")
|
options=("New instance" "Delete instance" "Add Camera" "USB port testing" "Create Backup" "Restore Backup" "Quit")
|
||||||
else
|
else
|
||||||
options=("Prepare system" "USB port testing" "Quit")
|
options=("Prepare system" "USB port testing" "Quit")
|
||||||
fi
|
fi
|
||||||
@@ -993,6 +1020,14 @@ main_menu() {
|
|||||||
usb_testing
|
usb_testing
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
"Create backup")
|
||||||
|
create_menu
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
"Restore backup")
|
||||||
|
restore_menu
|
||||||
|
break
|
||||||
|
;;
|
||||||
"Quit")
|
"Quit")
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user