#!/command/with-contenv /bin/bash source /assets/functions/00-container source /assets/defaults/10-db-backup source /assets/functions/10-db-backup PROCESS_NAME="db-backup-restore" oldcolumns=$COLUMNS ######################################################################################## ### System Functions ### ######################################################################################## ### Colours # Foreground (Text) Colors cdgy="\e[90m" # Color Dark Gray clg="\e[92m" # Color Light Green clm="\e[95m" # Color Light Magenta cwh="\e[97m" # Color White # Turns off all formatting coff="\e[0m" # Color Off # Background Colors bdr="\e[41m" # Background Color Dark Red bdg="\e[42m" # Background Color Dark Green bdb="\e[44m" # Background Color Dark Blue bdm="\e[45m" # Background Color Dark Magenta bdgy="\e[100m" # Background Color Dark Gray blr="\e[101m" # Background Color Light Red boff="\e[49m" # Background Color Off bootstrap_variables if [ -z "${1}" ] ; then interactive_mode=true else case "$1" in "-h" ) cat < If you only enter some of the arguments you will be prompted to fill them in. Other arguments -h This help screen EOF exit 0 ;; "-i" ) echo "interactive mode" interactive_mode=true ;; * ) interactive_mode=false ;; esac fi get_filename() { COLUMNS=12 prompt="Please select a file to restore:" options=( $(find "${DB_DUMP_TARGET}" -type f -maxdepth 1 -not -name '*.md5' -not -name '*.sha1' -print0 | xargs -0) ) PS3="$prompt " select opt in "${options[@]}" "Custom" "Quit" ; do if (( REPLY == 2 + ${#options[@]} )) ; then echo "Bye!" exit 2 elif (( REPLY == 1 + ${#options[@]} )) ; then while [ ! -f "${opt}" ] ; do read -p "What path and filename to restore: " opt if [ ! -f "${opt}" ] ; then print_error "File not found. Please retry.." fi done break elif (( REPLY > 0 && REPLY <= ${#options[@]} )) ; then break else echo "Invalid option. Try another one." fi done COLUMNS=$oldcolumns r_filename=${opt} } get_dbhost() { p_dbhost=$(basename -- "${r_filename}" | cut -d _ -f 3) if [ -n "${p_dbhost}" ]; then parsed_host=true print_debug "Parsed DBHost: ${p_dbhost}" fi if [ -z "${DB_HOST}" ] && [ -z "${parsed_host}" ]; then print_debug "Parsed DBHost Variant: 1 - No Env, No Parsed Filename" q_dbhost_variant=1 q_dbhost_menu=$(cat <