From: vados-dev Date: Thu, 12 Mar 2026 10:00:03 +0000 (+0300) Subject: Autocommit in repo: , generated by owner: mikro_bak, in 13:00:03 12.03.2026. X-Git-Url: https://git.vados.ru/gitweb.cgi?a=commitdiff_plain;h=0eabc978d8a199dc0a7df60d48ac68ec24e9c2f9;p=Mikrotiks%2FMikrotiks.git Autocommit in repo: , generated by owner: mikro_bak, in 13:00:03 12.03.2026. --- diff --git a/bin/Binary.backup b/bin/Binary.backup index 34a09ac..51950d3 100644 Binary files a/bin/Binary.backup and b/bin/Binary.backup differ diff --git a/bin/ros-diff.sh b/bin/ros-diff.sh index a62a2df..20950c8 100755 --- a/bin/ros-diff.sh +++ b/bin/ros-diff.sh @@ -116,7 +116,6 @@ section() { echo -e "\n${magenta}................[$(tput rev) $* ${reset}${magenta}]................${reset}\n" } - spinstr() { local -r pid="${1}" @@ -131,7 +130,7 @@ spinstr() sleep "${delay}" printf "\b\b\b\b\b\b" done - echo -ne "\\r[ ✔ ]\\n" #" \b\b\b\b" + echo -ne "\\r[ ✔ ]\\n" tput cnorm -- } @@ -271,8 +270,11 @@ run_ssh_cmd() { download_config() { local conf="${1}" local log_msg - - if ${SSH_STR} export >${conf}; then + ${SSH_STR} export >${conf} >/dev/null & pid=$! + spinstr "$pid" + wait "$pid" + rc=$? + if [ $rc -eq 0 ]; then log_msg="- Config download success!" log_success "${log_msg}" return 0 @@ -289,9 +291,8 @@ compare_config() { local diff_file="${3}" local diff_args=("${DEFAULT_DIFF_ARGS[@]}") local log_msg - warning "diff ${diff_args[*]} ${config_file} ${precedent_file} > ${diff_file}" + diff "${diff_args[@]}" ${config_file} ${precedent_file} >${diff_file} - exit 0 if [ "$?" -ne "0" ]; then log_msg="- There is a difference! Create backup..." if [ -t 1 ] && $DEBUG_OUT; then @@ -302,11 +303,11 @@ compare_config() { return 0 else log_msg="- The files are identical. No backup is required." + log_info "${log_msg}" if [ -t 1 ] && $DEBUG_OUT; then section " START CLEANUP " sleep 1 fi - log_info "${log_msg}" log_msg="- Remove ${diff_file} file." log_info "${log_msg}" ${CMD_RM} -f ${diff_file} @@ -342,10 +343,6 @@ check_directory() { fi } - # Examples: - # bin_pass="$(${SSH_STR} ':put [/system script environment get [find name=BackupPassword] value]')" - # bin_pass="$(${SSH_STR} ':put $BackupPassword')" # if BackupPassword is a global - backup_binary() { local bin_name="${1}" local bin_pass="${2:-$DEFAULT_BINPWD}" @@ -353,7 +350,9 @@ backup_binary() { local bin_tmp="Binary.backup" local log_msg local crypt_str - + # Examples: + # bin_pass="$(${SSH_STR} ':put [/system script environment get [find name=BackupPassword] value]')" + # bin_pass="$(${SSH_STR} ':put $BackupPassword')" # if BackupPassword is a global if [ -n "$(${SSH_STR} ':put $BackupEncrypt')" ] && [ -n "$(${SSH_STR} ':put $BackupPassword')" ] ; then crypt_str="dont-encrypt=no password=$(${SSH_STR} ':put $BackupPassword')" else @@ -364,19 +363,25 @@ backup_binary() { fi fi - local BKPSTR="/system backup save name=${bin_tmp} ${crypt_str}" - local T_BKPCLN="/file remove [find name=${bin_tmp}]" - ${SSH_STR} "/system backup save name=${bin_tmp} ${crypt_str}" >/dev/null & spinstr "$!" - if [ $? -eq 0 ]; then + log_msg="Create ${bin_tmp} file on ${RouterName}..." + log_info "${log_msg}" + + ${SSH_STR} "/system backup save name=${bin_tmp} ${crypt_str}" >/dev/null & pid=$! + spinstr "$pid" + wait "$pid" + rc=$? + if [ $rc -eq 0 ]; then log_msg="Create binary backup ${bin_tmp} on ${RouterName} success." log_success "${log_msg}" log_msg="- Start download ${bin_tmp} file to ${BackupDir}..." log_info "${log_msg}" - ${SCP_STR}:/${bin_tmp} ${bin_name} & spinstr "$!" - if [ $? -eq 0 ]; then - sleep 2 + ${SCP_STR}:/${bin_tmp} ${bin_name} >/dev/null & pid=$! + spinstr "$pid" + wait "$pid" + rc=$? + if [ $rc -eq 0 ]; then log_msg="- Binary Backup download complete!" log_success "${log_msg}" else @@ -395,16 +400,15 @@ backup_binary() { log_info "${log_msg}" if ${SSH_STR} "/file remove [find name=${bin_tmp}]"; then - log_msg="- Remove ${bin_tmp} file on ${RouterName} complete succesfully!" - log_success "${log_msg}" + log_msg="- Remove ${bin_tmp} file on ${RouterName} complete succesfully!" + log_success "${log_msg}" else - log_msg="- Error Remove ${bin_tmp} file on ${RouterName}!" - log_error "${log_msg}" + log_msg="- Error Remove ${bin_tmp} file on ${RouterName}!" + log_error "${log_msg}" fi } readarray -t lines < $HostsFile - for HR in "${lines[@]}"; do while IFS=$' ' read -a HR ; do [[ -z ${HR[0]} ]] && continue @@ -419,12 +423,6 @@ SSHuser=${HR[3]} backup_pass=${HR[4]} get_connections_str -#backup_binary "BinaryTest.backup" - -#exit 0 -#warning "SSH_STR = ${SSH_STR}" -#warning "SCP_STR = ${SCP_STR}" -#exit 0 BaseDir=${HomeDir}"/backups/${RouterName}/" TempDir=${BaseDir}"tmp/" @@ -491,14 +489,10 @@ if compare_config ${current_config} ${precedent_config} ${diff_config} ${RouterN log_msg="- Copy configuration to ${BackupDir}/${save_config} and ${precedent_config} success." log_success "${log_msg}" - log_msg="Create ${bin_tmp} file on ${RouterName}..." - log_info "${log_msg}" - backup_binary ${bin_tmp} ${backup_pass} -# if [ $? -eq 0 ]; then - + cd "${BaseDir}" - + CurrentHistoryDir=${HistoryDir}"${DStamp}/" ${CMD_MKD} -p ${CurrentHistoryDir} diff_config_history=${CurrentHistoryDir}"${DTStamp}-Diff-Config.rsc" @@ -553,8 +547,6 @@ log_success "${log_msg}" done <<<"$(echo -e $HR)" LogFile="${DEFAULT_LOG}" RouterName="" -# echo -ne "\\r[${BAR_SIZE:0:percBar}] $perc %" -#echo "[] $perc %" done if [ -t 1 ] && $DEBUG_OUT; then