feat: moonraker.conf backup function
Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
@@ -35,7 +35,7 @@ function backup_printer_cfg() {
|
|||||||
check_for_backup_dir
|
check_for_backup_dir
|
||||||
local current_date
|
local current_date
|
||||||
|
|
||||||
if [[ -f "${PRINTER_CFG}" ]]; then
|
if [[ -f ${PRINTER_CFG} ]]; then
|
||||||
current_date=$(get_date)
|
current_date=$(get_date)
|
||||||
status_msg "Timestamp: ${current_date}"
|
status_msg "Timestamp: ${current_date}"
|
||||||
status_msg "Create backup of printer.cfg ..."
|
status_msg "Create backup of printer.cfg ..."
|
||||||
@@ -70,7 +70,7 @@ function backup_moonraker_database() {
|
|||||||
local current_date databases target_dir
|
local current_date databases target_dir
|
||||||
databases=$(find "${HOME}" -maxdepth 1 -type d -regextype posix-extended -regex "${HOME}/.moonraker_database(_[^0])?[0-9]*" | sort)
|
databases=$(find "${HOME}" -maxdepth 1 -type d -regextype posix-extended -regex "${HOME}/.moonraker_database(_[^0])?[0-9]*" | sort)
|
||||||
|
|
||||||
if [[ -n "${databases}" ]]; then
|
if [[ -n ${databases} ]]; then
|
||||||
current_date=$(get_date)
|
current_date=$(get_date)
|
||||||
target_dir="${BACKUP_DIR}/moonraker_database_backup/${current_date}"
|
target_dir="${BACKUP_DIR}/moonraker_database_backup/${current_date}"
|
||||||
|
|
||||||
@@ -90,6 +90,36 @@ function backup_moonraker_database() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
# Helper function to back up all moonraker.conf files located in
|
||||||
|
# ${KLIPPER_CONFIG} and its subfolders
|
||||||
|
###
|
||||||
|
function backup_moonraker_conf() {
|
||||||
|
check_for_backup_dir
|
||||||
|
local current_date configs target_dir
|
||||||
|
configs=$(find "${KLIPPER_CONFIG}" -type f -name "moonraker.conf" | sort)
|
||||||
|
|
||||||
|
if [[ -n ${configs} ]]; then
|
||||||
|
current_date=$(get_date)
|
||||||
|
target_dir="${BACKUP_DIR}/moonraker_conf_backup/${current_date}"
|
||||||
|
|
||||||
|
status_msg "Timestamp: ${current_date}"
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
|
||||||
|
for config in ${configs}; do
|
||||||
|
status_msg "Create backup of ${config} ..."
|
||||||
|
cp -r "${config}" "${target_dir}"
|
||||||
|
ok_msg "Done!"
|
||||||
|
done
|
||||||
|
|
||||||
|
print_confirm "Backup of all moonraker.conf complete!"
|
||||||
|
|
||||||
|
else
|
||||||
|
print_error "No moonraker.conf found! Skipping backup ..."
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
function backup_klipper() {
|
function backup_klipper() {
|
||||||
local current_date
|
local current_date
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user