Upload v2.0

Uploading a complete rewrite of the original script.
This commit is contained in:
th33xitus
2020-07-13 16:59:40 +02:00
committed by GitHub
parent 1eecf3e139
commit d7ff3f8675
12 changed files with 1811 additions and 774 deletions

74
scripts/backup.sh Normal file
View File

@@ -0,0 +1,74 @@
backup_printer_cfg(){
if [ ! -d $BACKUP_DIR ]; then
status_msg "Create backup directory ..."
mkdir -p $BACKUP_DIR && ok_msg "Directory created!"
fi
if [ -f $PRINTER_CFG ]; then
get_date
status_msg "Create backup of printer.cfg ..."
cp $PRINTER_CFG $BACKUP_DIR/printer.cfg."$current_date".backup && ok_msg "Backup created!"
else
ok_msg "No printer.cfg found! Skipping backup ..."
fi
}
read_bb4u_stat(){
source_ini
if [ ! "$backup_before_update" = "true" ]; then
BB4U_STATUS="${green}[Enable]${default} backups before updating "
else
BB4U_STATUS="${red}[Disable]${default} backups before updating "
fi
}
toggle_backups(){
source_ini
if [ "$backup_before_update" = "true" ]; then
sed -i '/backup_before_update=/s/true/false/' ${HOME}/kiauh2/kiauh.ini
BB4U_STATUS="${green}[Enable]${default} backups before updating "
fi
if [ "$backup_before_update" = "false" ]; then
sed -i '/backup_before_update=/s/false/true/' ${HOME}/kiauh2/kiauh.ini
BB4U_STATUS="${red}[Disable]${default} backups before updating "
fi
}
bb4u_klipper(){
source_ini
if [ -d $KLIPPER_DIR ] && [ "$backup_before_update" = "true" ]; then
get_date
status_msg "Creating Klipper backup ..."
mkdir -p $BACKUP_DIR/klipper-backups/"$current_date"
cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV_DIR $_ && ok_msg "Backup complete!"
fi
}
bb4u_dwc2fk(){
source_ini
if [ -d $DWC2FK_DIR ] && [ "$backup_before_update" = "true" ]; then
get_date
status_msg "Creating DWC2-for-Klipper backup ..."
mkdir -p $BACKUP_DIR/dwc2-for-klipper-backups/"$current_date"
cp -r $DWC2FK_DIR $_ && ok_msg "Backup complete!"
fi
}
bb4u_dwc2(){
source_ini
if [ -d $DWC2_DIR ] && [ "$backup_before_update" = "true" ]; then
get_date
status_msg "Creating DWC2 Web UI backup ..."
mkdir -p $BACKUP_DIR/dwc2-backups/"$current_date"
cp -r $DWC2_DIR $_ && ok_msg "Backup complete!"
fi
}
bb4u_mainsail(){
source_ini
if [ -d $MAINSAIL_DIR ] && [ "$backup_before_update" = "true" ]; then
get_date
status_msg "Creating Mainsail backup ..."
mkdir -p $BACKUP_DIR/mainsail-backups/"$current_date"
cp -r $MAINSAIL_DIR $_ && ok_msg "Backup complete!"
fi
}