From 2bae9bc6ce27bfbcbd0f9ccd9c86a2ac9cbf51d9 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Sat, 7 Mar 2026 10:56:39 -0500 Subject: [PATCH] feat: Add DBRepair installation and management features to Plex scripts --- plex/plex-db-manager.sh | 261 ++++++++++++++++++++++++++++++++++++++- plex/plex.sh | 265 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 522 insertions(+), 4 deletions(-) diff --git a/plex/plex-db-manager.sh b/plex/plex-db-manager.sh index f6cd70e..d357d16 100755 --- a/plex/plex-db-manager.sh +++ b/plex/plex-db-manager.sh @@ -57,6 +57,10 @@ readonly SCRIPT_DIR readonly LOG_FILE="$SCRIPT_DIR/logs/db-manager-$(date +%Y%m%d_%H%M%S).log" # DBRepair.sh location — searched in order: script dir, database dir, /usr/local/bin +readonly DBREPAIR_INSTALL_PATH="${SCRIPT_DIR}/DBRepair.sh" +readonly DBREPAIR_GITHUB_API="https://api.github.com/repos/ChuckPa/PlexDBRepair/releases" +readonly DBREPAIR_DOWNLOAD_BASE="https://github.com/ChuckPa/PlexDBRepair/releases/download" + find_dbrepair() { local candidates=( "${SCRIPT_DIR}/DBRepair.sh" @@ -72,6 +76,231 @@ find_dbrepair() { return 1 } +# Get the latest non-beta release tag from GitHub +_dbrepair_latest_release_tag() { + local tag + tag=$(curl -fsSL "${DBREPAIR_GITHUB_API}" 2>/dev/null \ + | grep -Eo '"tag_name"\s*:\s*"[^"]+"' \ + | head -n 1 \ + | sed 's/"tag_name"\s*:\s*"//;s/"//') + if [[ -z "$tag" ]]; then + return 1 + fi + echo "$tag" +} + +# Get currently installed DBRepair version +_dbrepair_installed_version() { + local bin="$1" + grep -oP 'Version\s+v\K[0-9.]+' "$bin" 2>/dev/null | head -n 1 +} + +# Install or update DBRepair.sh +install_or_update_dbrepair() { + log_message "Checking DBRepair (ChuckPa/PlexDBRepair)..." + + local latest_tag + if ! latest_tag=$(_dbrepair_latest_release_tag); then + log_error "Failed to query GitHub for the latest release" + log_warning "Check your internet connection or try: https://github.com/ChuckPa/PlexDBRepair/releases" + return 1 + fi + log_message "Latest stable release: ${latest_tag}" + + local dbrepair_bin + if dbrepair_bin=$(find_dbrepair); then + local installed_ver + installed_ver=$(_dbrepair_installed_version "$dbrepair_bin") + local remote_ver + remote_ver=$(echo "$latest_tag" | sed 's/^v//') + + if [[ -n "$installed_ver" ]]; then + log_message "Installed version: v${installed_ver} at ${dbrepair_bin}" + if [[ "$installed_ver" == "$remote_ver" ]]; then + log_success "DBRepair is already up to date (v${installed_ver})" + return 0 + else + log_warning "Update available: v${installed_ver} -> ${latest_tag}" + fi + else + log_warning "Installed at ${dbrepair_bin} (version unknown), will update" + fi + else + log_message "DBRepair not found — installing to ${DBREPAIR_INSTALL_PATH}" + fi + + local download_url="${DBREPAIR_DOWNLOAD_BASE}/${latest_tag}/DBRepair.sh" + log_message "Downloading ${download_url}" + if curl -fsSL -o "${DBREPAIR_INSTALL_PATH}" "$download_url"; then + chmod +x "${DBREPAIR_INSTALL_PATH}" + log_success "DBRepair ${latest_tag} installed to ${DBREPAIR_INSTALL_PATH}" + return 0 + else + log_error "Download failed" + rm -f "${DBREPAIR_INSTALL_PATH}" 2>/dev/null + return 1 + fi +} + +# Suggest installing DBRepair when errors are found and it's not available +_hint_install_dbrepair() { + if ! find_dbrepair >/dev/null 2>&1; then + echo "" + log_warning "DBRepair is NOT installed. It can fix most database issues automatically." + echo -e " ${CYAN}Install it now: $(basename "$0") install-dbrepair${RESET}" + echo -e " ${CYAN}Then repair: $(basename "$0") repair${RESET}" + fi +} + +# List and manage database backup files +list_db_backups() { + local db_dir="$PLEX_DB_DIR" + local -a backup_files=() + local -a backup_paths=() + + while IFS= read -r -d '' entry; do + backup_paths+=("$entry") + done < <(sudo find "$db_dir" -maxdepth 1 \( \ + -name '*-BACKUP-*' -o \ + -name '*-BKUP-*' -o \ + -name '*.backup.*' -o \ + -name '*recovery*' -o \ + -name 'corrupted-*' -o \ + -name '*-BLOATED-*' \ + \) -print0 2>/dev/null | sort -z) + + if [[ ${#backup_paths[@]} -eq 0 ]]; then + log_message "No database backup files found in the Plex database directory" + return 0 + fi + + echo -e "\n${BOLD}${WHITE} # Type Size Created Name${RESET}" + echo -e " --- ------------- ----------- ------------------------ ------------------------------------" + + local idx=0 + for entry in "${backup_paths[@]}"; do + ((idx++)) + local name + name=$(basename "$entry") + + local type_label + if [[ "$name" == *-BACKUP-* || "$name" == *-BKUP-* ]]; then + type_label="DBRepair" + elif [[ "$name" == *-BLOATED-* ]]; then + type_label="Bloated" + elif [[ "$name" == *.backup.* ]]; then + type_label="Script" + elif [[ "$name" == corrupted-* ]]; then + type_label="Corrupted" + elif [[ "$name" == *recovery* ]]; then + type_label="Recovery" + else + type_label="Other" + fi + + local size + if [[ -d "$entry" ]]; then + size=$(sudo du -sh "$entry" 2>/dev/null | cut -f1) + type_label="${type_label}/dir" + else + size=$(sudo stat --printf='%s' "$entry" 2>/dev/null) + if [[ -n "$size" ]]; then + size=$(numfmt --to=iec-i --suffix=B "$size" 2>/dev/null || echo "${size}B") + else + size="?" + fi + fi + + local created + created=$(sudo stat --printf='%y' "$entry" 2>/dev/null | cut -d. -f1) + [[ -z "$created" ]] && created="unknown" + + printf " ${WHITE}%-3s${RESET} ${CYAN}%-13s${RESET} ${YELLOW}%-11s${RESET} %-24s %s\n" \ + "$idx" "$type_label" "$size" "$created" "$name" + + backup_files+=("$entry") + done + + echo -e " --- ------------- ----------- ------------------------ ------------------------------------" + echo -e " Total: ${idx} backup file(s)\n" + + _BACKUP_LIST=("${backup_files[@]}") + _BACKUP_COUNT=$idx +} + +# Interactive backup deletion +delete_db_backups_interactive() { + list_db_backups + if [[ ${_BACKUP_COUNT:-0} -eq 0 ]]; then + return 0 + fi + + echo -e "${CYAN}Enter backup number(s) to delete (comma-separated), or 'q' to cancel:${RESET} " + read -r selection + + if [[ "$selection" == "q" || -z "$selection" ]]; then + log_message "Cancelled" + return 0 + fi + + IFS=',' read -ra nums <<< "$selection" + local deleted=0 + for num in "${nums[@]}"; do + num=$(echo "$num" | tr -d ' ') + if ! [[ "$num" =~ ^[0-9]+$ ]] || (( num < 1 || num > _BACKUP_COUNT )); then + log_error "Invalid selection: $num (skipping)" + continue + fi + local target="${_BACKUP_LIST[$((num-1))]}" + local target_name + target_name=$(basename "$target") + echo -e "${YELLOW}Delete ${target_name}? [y/N]:${RESET} " + read -r confirm + if [[ "${confirm,,}" == "y" ]]; then + if [[ -d "$target" ]]; then + sudo rm -rf "$target" + else + sudo rm -f "$target" + fi + log_success "Deleted: $target_name" + ((deleted++)) + else + log_message "Skipped: $target_name" + fi + done + echo "" + log_message "Deleted $deleted backup(s)" +} + +# Delete backup by name/pattern +delete_db_backup_by_name() { + local pattern="$1" + local db_dir="$PLEX_DB_DIR" + local found=0 + + while IFS= read -r -d '' entry; do + local name + name=$(basename "$entry") + echo -e "${YELLOW}Delete ${name}? [y/N]:${RESET} " + read -r confirm + if [[ "${confirm,,}" == "y" ]]; then + if [[ -d "$entry" ]]; then + sudo rm -rf "$entry" + else + sudo rm -f "$entry" + fi + log_success "Deleted: $name" + ((found++)) + fi + done < <(sudo find "$db_dir" -maxdepth 1 -name "*${pattern}*" -print0 2>/dev/null) + + if [[ $found -eq 0 ]]; then + log_error "No backups matching '${pattern}' found" + return 1 + fi + log_message "Deleted $found file(s)" +} + # Create log directory mkdir -p "$SCRIPT_DIR/logs" @@ -298,6 +527,7 @@ check_all_databases() { return 0 else log_warning "Found integrity issues in $issues database(s)" + _hint_install_dbrepair return 1 fi } @@ -312,12 +542,18 @@ show_help() { echo -e " ${YELLOW}${BOLD}repair --gentle${RESET} Gentle repair methods only" echo -e " ${RED}${BOLD}repair --force${RESET} Aggressive repair methods" echo -e " ${RED}${BOLD}nuclear${RESET} Nuclear recovery (replace from backup)" + echo -e " ${CYAN}${BOLD}backups${RESET} List and manage database backup files" + echo -e " ${GREEN}${BOLD}install-dbrepair${RESET} Install or update DBRepair tool" echo -e " ${CYAN}${BOLD}help${RESET} Show this help message" echo "" echo -e "${BOLD}${WHITE}Examples:${RESET}" echo -e " ${DIM}$(basename "$0") check # Safe integrity check${RESET}" echo -e " ${DIM}$(basename "$0") repair # Interactive repair${RESET}" echo -e " ${DIM}$(basename "$0") repair --gentle # Minimal repair only${RESET}" + echo -e " ${DIM}$(basename "$0") backups # List DB backups${RESET}" + echo -e " ${DIM}$(basename "$0") backups delete # Interactive backup deletion${RESET}" + echo -e " ${DIM}$(basename "$0") backups delete --name foo # Delete by name pattern${RESET}" + echo -e " ${DIM}$(basename "$0") install-dbrepair # Install/update DBRepair${RESET}" echo "" echo -e "${BOLD}${YELLOW}⚠️ WARNING:${RESET} Always run ${CYAN}check${RESET} first before attempting repairs!" echo "" @@ -375,9 +611,8 @@ main() { fi else echo -e "${RED}${BOLD}⚠️ DBRepair.sh NOT FOUND${RESET}" - echo -e "${YELLOW}Install DBRepair for repair/optimize/reindex/FTS-rebuild:${RESET}" - echo -e " ${CYAN}wget -O ${SCRIPT_DIR}/DBRepair.sh https://github.com/ChuckPa/PlexDBRepair/releases/latest/download/DBRepair.sh${RESET}" - echo -e " ${CYAN}chmod +x ${SCRIPT_DIR}/DBRepair.sh${RESET}" + echo -e "${YELLOW}You can install it automatically:${RESET}" + echo -e " ${CYAN}$(basename "$0") install-dbrepair${RESET}" echo -e "${YELLOW}Then re-run: $(basename "$0") repair${RESET}" exit 2 fi @@ -432,7 +667,25 @@ main() { print_header show_help ;; - + + "install-dbrepair"|"update-dbrepair"|"dbrepair") + print_header + install_or_update_dbrepair + ;; + + "backups"|"backup-list") + print_header + if [[ $# -ge 2 && "${2,,}" == "delete" ]]; then + if [[ $# -ge 4 && "${3}" == "--name" ]]; then + delete_db_backup_by_name "$4" + else + delete_db_backups_interactive + fi + else + list_db_backups + fi + ;; + *) print_header log_error "Unknown command: $1" diff --git a/plex/plex.sh b/plex/plex.sh index 10e2d82..f3d415d 100755 --- a/plex/plex.sh +++ b/plex/plex.sh @@ -78,6 +78,10 @@ SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" readonly SCRIPT_DIR # DBRepair.sh location — searched in order: script dir, database dir, /usr/local/bin +readonly DBREPAIR_INSTALL_PATH="${SCRIPT_DIR}/DBRepair.sh" +readonly DBREPAIR_GITHUB_API="https://api.github.com/repos/ChuckPa/PlexDBRepair/releases" +readonly DBREPAIR_DOWNLOAD_BASE="https://github.com/ChuckPa/PlexDBRepair/releases/download" + find_dbrepair() { local candidates=( "${SCRIPT_DIR}/DBRepair.sh" @@ -93,6 +97,245 @@ find_dbrepair() { return 1 } +# Get the latest non-beta release tag from GitHub +_dbrepair_latest_release_tag() { + # Fetch releases, filter out pre-releases & drafts, grab the first tag_name + local tag + tag=$(curl -fsSL "${DBREPAIR_GITHUB_API}" 2>/dev/null \ + | grep -Eo '"tag_name"\s*:\s*"[^"]+"' \ + | head -n 1 \ + | sed 's/"tag_name"\s*:\s*"//;s/"//') + if [[ -z "$tag" ]]; then + return 1 + fi + echo "$tag" +} + +# Get currently installed DBRepair version (from its own version output) +_dbrepair_installed_version() { + local bin="$1" + # DBRepair prints "Version vX.YY.ZZ" near the top when run interactively; + # we can also grep the script file itself for the version string. + grep -oP 'Version\s+v\K[0-9.]+' "$bin" 2>/dev/null | head -n 1 +} + +# Install or update DBRepair.sh +install_or_update_dbrepair() { + print_status "${INFO}" "Checking DBRepair (ChuckPa/PlexDBRepair)..." "${BLUE}" + + # Determine latest non-beta release + local latest_tag + if ! latest_tag=$(_dbrepair_latest_release_tag); then + print_status "${CROSS}" "Failed to query GitHub for the latest release" "${RED}" + print_status "${INFO}" "Check your internet connection or try: https://github.com/ChuckPa/PlexDBRepair/releases" "${YELLOW}" + return 1 + fi + print_status "${INFO}" "Latest stable release: ${latest_tag}" "${BLUE}" + + # Check if already installed + local dbrepair_bin + if dbrepair_bin=$(find_dbrepair); then + local installed_ver + installed_ver=$(_dbrepair_installed_version "$dbrepair_bin") + local remote_ver + remote_ver=$(echo "$latest_tag" | sed 's/^v//') + + if [[ -n "$installed_ver" ]]; then + print_status "${INFO}" "Installed version: v${installed_ver} at ${dbrepair_bin}" "${BLUE}" + if [[ "$installed_ver" == "$remote_ver" ]]; then + print_status "${CHECKMARK}" "DBRepair is already up to date (v${installed_ver})" "${GREEN}" + return 0 + else + print_status "${INFO}" "Update available: v${installed_ver} -> ${latest_tag}" "${YELLOW}" + fi + else + print_status "${INFO}" "Installed at ${dbrepair_bin} (version unknown), will update" "${YELLOW}" + fi + else + print_status "${INFO}" "DBRepair not found — installing to ${DBREPAIR_INSTALL_PATH}" "${BLUE}" + fi + + # Download + local download_url="${DBREPAIR_DOWNLOAD_BASE}/${latest_tag}/DBRepair.sh" + print_status "${INFO}" "Downloading ${download_url}" "${BLUE}" + if curl -fsSL -o "${DBREPAIR_INSTALL_PATH}" "$download_url"; then + chmod +x "${DBREPAIR_INSTALL_PATH}" + print_status "${CHECKMARK}" "DBRepair ${latest_tag} installed to ${DBREPAIR_INSTALL_PATH}" "${GREEN}" + return 0 + else + print_status "${CROSS}" "Download failed" "${RED}" + rm -f "${DBREPAIR_INSTALL_PATH}" 2>/dev/null + return 1 + fi +} + +# Suggest installing DBRepair when errors are found and it's not available +_hint_install_dbrepair() { + if ! find_dbrepair >/dev/null 2>&1; then + echo "" + print_status "${INFO}" "DBRepair is NOT installed. It can fix most database issues automatically." "${YELLOW}" + echo -e "${DIM}${CYAN} Install it now: ${SCRIPT_NAME} install-dbrepair${RESET}" + echo -e "${DIM}${CYAN} Then repair: ${SCRIPT_NAME} repair${RESET}" + fi +} + +# 📦 List and manage database backup files +# Covers: DBRepair backups (-BACKUP-*, -BKUP-*), script backups (*.backup.*), +# corrupted dirs (corrupted-*), recovery files (*recovery*) +list_db_backups() { + local db_dir="$PLEX_DB_DIR" + local -a backup_files=() + local -a backup_paths=() + + # Collect all backup-like files and dirs + while IFS= read -r -d '' entry; do + backup_paths+=("$entry") + done < <(sudo find "$db_dir" -maxdepth 1 \( \ + -name '*-BACKUP-*' -o \ + -name '*-BKUP-*' -o \ + -name '*.backup.*' -o \ + -name '*recovery*' -o \ + -name 'corrupted-*' -o \ + -name '*-BLOATED-*' \ + \) -print0 2>/dev/null | sort -z) + + if [[ ${#backup_paths[@]} -eq 0 ]]; then + print_status "${INFO}" "No database backup files found in the Plex database directory" "${YELLOW}" + return 0 + fi + + echo -e "\n${BOLD}${WHITE} # Type Size Created Name${RESET}" + echo -e "${DIM}${CYAN} --- ------------- ----------- ------------------------ ------------------------------------${RESET}" + + local idx=0 + for entry in "${backup_paths[@]}"; do + ((idx++)) + local name + name=$(basename "$entry") + + # Determine type label + local type_label + if [[ "$name" == *-BACKUP-* || "$name" == *-BKUP-* ]]; then + type_label="DBRepair" + elif [[ "$name" == *-BLOATED-* ]]; then + type_label="Bloated" + elif [[ "$name" == *.backup.* ]]; then + type_label="Script" + elif [[ "$name" == corrupted-* ]]; then + type_label="Corrupted" + elif [[ "$name" == *recovery* ]]; then + type_label="Recovery" + else + type_label="Other" + fi + + # Size (human-readable) + local size + if [[ -d "$entry" ]]; then + size=$(sudo du -sh "$entry" 2>/dev/null | cut -f1) + type_label="${type_label}/dir" + else + size=$(sudo stat --printf='%s' "$entry" 2>/dev/null) + if [[ -n "$size" ]]; then + size=$(numfmt --to=iec-i --suffix=B "$size" 2>/dev/null || echo "${size}B") + else + size="?" + fi + fi + + # Created date + local created + created=$(sudo stat --printf='%y' "$entry" 2>/dev/null | cut -d. -f1) + [[ -z "$created" ]] && created="unknown" + + printf " ${WHITE}%-3s${RESET} ${CYAN}%-13s${RESET} ${YELLOW}%-11s${RESET} ${DIM}%-24s${RESET} %s\n" \ + "$idx" "$type_label" "$size" "$created" "$name" + + backup_files+=("$entry") + done + + echo -e "${DIM}${CYAN} --- ------------- ----------- ------------------------ ------------------------------------${RESET}" + echo -e " ${DIM}Total: ${idx} backup file(s)${RESET}\n" + + # Store for use by delete function + _BACKUP_LIST=("${backup_files[@]}") + _BACKUP_COUNT=$idx +} + +# Interactive backup deletion +delete_db_backups_interactive() { + list_db_backups + if [[ ${_BACKUP_COUNT:-0} -eq 0 ]]; then + return 0 + fi + + echo -e "${CYAN}Enter backup number(s) to delete (comma-separated), or 'q' to cancel:${RESET} " + read -r selection + + if [[ "$selection" == "q" || -z "$selection" ]]; then + print_status "${INFO}" "Cancelled" "${YELLOW}" + return 0 + fi + + # Parse comma-separated numbers + IFS=',' read -ra nums <<< "$selection" + local deleted=0 + for num in "${nums[@]}"; do + num=$(echo "$num" | tr -d ' ') + if ! [[ "$num" =~ ^[0-9]+$ ]] || (( num < 1 || num > _BACKUP_COUNT )); then + print_status "${CROSS}" "Invalid selection: $num (skipping)" "${RED}" + continue + fi + local target="${_BACKUP_LIST[$((num-1))]}" + local target_name + target_name=$(basename "$target") + echo -e "${YELLOW}Delete ${target_name}? [y/N]:${RESET} " + read -r confirm + if [[ "${confirm,,}" == "y" ]]; then + if [[ -d "$target" ]]; then + sudo rm -rf "$target" + else + sudo rm -f "$target" + fi + print_status "${CHECKMARK}" "Deleted: $target_name" "${GREEN}" + ((deleted++)) + else + print_status "${INFO}" "Skipped: $target_name" "${YELLOW}" + fi + done + echo "" + print_status "${INFO}" "Deleted $deleted backup(s)" "${BLUE}" +} + +# Delete backup by name/pattern (for scripted use) +delete_db_backup_by_name() { + local pattern="$1" + local db_dir="$PLEX_DB_DIR" + local found=0 + + while IFS= read -r -d '' entry; do + local name + name=$(basename "$entry") + echo -e "${YELLOW}Delete ${name}? [y/N]:${RESET} " + read -r confirm + if [[ "${confirm,,}" == "y" ]]; then + if [[ -d "$entry" ]]; then + sudo rm -rf "$entry" + else + sudo rm -f "$entry" + fi + print_status "${CHECKMARK}" "Deleted: $name" "${GREEN}" + ((found++)) + fi + done < <(sudo find "$db_dir" -maxdepth 1 -name "*${pattern}*" -print0 2>/dev/null) + + if [[ $found -eq 0 ]]; then + print_status "${CROSS}" "No backups matching '${pattern}' found" "${RED}" + return 1 + fi + print_status "${INFO}" "Deleted $found file(s)" "${BLUE}" +} + # 🎭 ASCII symbols for compatible output readonly CHECKMARK="[✓]" readonly CROSS="[✗]" @@ -353,6 +596,7 @@ check_database_integrity() { fi print_status "${INFO}" "Consider running database repair: ${SCRIPT_NAME} repair" "${YELLOW}" + _hint_install_dbrepair return 1 } @@ -374,6 +618,7 @@ start_plex() { if ! check_database_integrity; then print_status "${INFO}" "Database integrity issues detected — starting Plex anyway (it may self-repair)." "${YELLOW}" echo -e "${DIM}${YELLOW} If Plex fails to start, run: ${SCRIPT_NAME} repair${RESET}" + _hint_install_dbrepair fi print_status "${INFO}" "Attempting to start service..." "${BLUE}" @@ -537,6 +782,8 @@ show_help() { echo -e " ${PURPLE}${BOLD}scan${RESET} ${SPARKLES} Library scanner operations" echo -e " ${RED}${BOLD}repair${RESET} [!] Repair database corruption issues" echo -e " ${RED}${BOLD}nuclear${RESET} [!!] Nuclear database recovery (last resort)" + echo -e " ${CYAN}${BOLD}backups${RESET} [#] List and manage database backup files" + echo -e " ${GREEN}${BOLD}install-dbrepair${RESET} Install or update DBRepair tool" echo -e " ${PURPLE}${BOLD}help${RESET} [*] Show this help message" echo "" echo -e "${DIM}${WHITE}Examples:${RESET}" @@ -545,6 +792,10 @@ show_help() { echo -e " ${DIM}${SCRIPT_NAME} scan # Launch library scanner interface${RESET}" echo -e " ${DIM}${SCRIPT_NAME} repair # Fix database issues${RESET}" echo -e " ${DIM}${SCRIPT_NAME} nuclear # Complete database replacement${RESET}" + echo -e " ${DIM}${SCRIPT_NAME} backups # List and manage DB backups${RESET}" + echo -e " ${DIM}${SCRIPT_NAME} backups delete # Interactive backup deletion${RESET}" + echo -e " ${DIM}${SCRIPT_NAME} backups delete --name foo # Delete by name pattern${RESET}" + echo -e " ${DIM}${SCRIPT_NAME} install-dbrepair # Install/update DBRepair${RESET}" echo "" } @@ -712,6 +963,20 @@ main() { "nuclear"|"nuke") nuclear_recovery ;; + "install-dbrepair"|"update-dbrepair"|"dbrepair") + install_or_update_dbrepair + ;; + "backups"|"backup-list") + if [[ $# -ge 2 && "${2,,}" == "delete" ]]; then + if [[ $# -ge 4 && "${3}" == "--name" ]]; then + delete_db_backup_by_name "$4" + else + delete_db_backups_interactive + fi + else + list_db_backups + fi + ;; "help"|"--help"|"-h") show_help ;;