TiNa - Backup Hosts Summary

Ce script bash génère un rapport de synthèse de l’environnement de sauvegarde TiNa. Il affiche les informations de base du serveur, liste les hôtes configurés pour les sauvegardes dans TiNa, vérifie l’état des agents TiNa sur plusieurs machines, affiche la taille et le contenu des répertoires de catalogues, et liste les cartouches recyclables disponibles pour les prochaines opérations de sauvegarde.

Scrip Bash

Ce script est à paramétrer dans la crontab afin de générer régulièrement un résumé complet sur l’état des hosts couverts par TiNa.

#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Last version : 2024-09-25
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# README ═══════════════════════════════════════════════════════════════════════════════════════════
# This script
# - Displays basic information of the host
# - Lists the hosts saved by TiNa
# - Displays the size of the directory where the catalogs are saved
# - Displays the last catalog(s) saved
# The following line shall be added to the crontab ----------------------------------------------
# 00 7 * * 1 /root/TiNa-scripts/TiNa-HostsList.sh | mailx -v -s "[TiNa] - Backup informations of $HOSTNAME" -S smtp=mail.my.company.org -S from="[email protected]" [email protected]
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

#=======================================
# VARIABLES DEFINITION
#=======================================
TiNa_PATH_INSTALL=/usr/Atempo/TimeNavigator/myCatalog/Bin/
TiNa_PATH_CATALOG_G=/tina-catalogue/
TiNa_PATH_CATALOG=/tina-catalogue/catalog_backup/
MAIL_TEMP_FILE=/tmp/TiNa.log

#=======================================
# MAIL HEADER SUMMARY HOST
#=======================================
tina_host_summary(){

# Host Summary

echo -e "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ BACKUP SUMMARY OF $HOSTNAME"
echo -e "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ Date: $(date +%Y-%m-%d)"
echo -e "┃ Uptime: $(uptime | awk -F'up ' '{print $2}' | awk -F',' '{print $1}')"
echo -e "┃ System: $(cat /etc/redhat-release)"
echo -e "┃ Kernel: $(uname -r)"
echo -e "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
}


#=======================================
# Hosts backuped list
#=======================================
tina_list_host(){

# List the host backuped by TiNa

echo -e "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ HOSTS BACKUPED BY TINA"
echo -e "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ Number of hosts: $(${TiNa_PATH_INSTALL}tina_config | grep HOST: | wc -l)"
echo -e "┃-------------------------------------------------------------------"
echo -e "┃ Listing:"
${TiNa_PATH_INSTALL}/tina_config | awk '
/HOST:/ {host=$2 " " $3}
/Comment:/ {comment=substr($0, index($0,$3))}
/Use *:/ {use=$4}
(host != "" && comment != "" && use != "") {print "┃ " use " - " host " - " comment; host=""; comment=""; use=""}'
echo -e "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
}

#=======================================
# LAST CATALOG(S) BACKUP & DIRECTORY SIZE
#=======================================
backup_catalog_size(){

# Backup catalog & directory size

echo -e "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ CATALOG DIRECTORY"
echo -e "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ Size of directory ${TiNa_PATH_CATALOG_G}:"
echo -e "$(du -sh "${TiNa_PATH_CATALOG_G}" | awk '{print "┃ =>", $1}')"
echo -e "┃-------------------------------------------------------------------"
echo -e "┃ Current files:"
echo -e "$(ls -rtlh "${TiNa_PATH_CATALOG_G}" | sed 's/^/┃ /')"
echo -e "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ Size of directory ${TiNa_PATH_CATALOG}:"
echo -e "$(du -sh "${TiNa_PATH_CATALOG}" | awk '{print "┃ =>", $1}')"
echo -e "┃-------------------------------------------------------------------"
echo -e "┃ Current files:"
echo -e "$(ls -rtlh "${TiNa_PATH_CATALOG}" | sed 's/^/┃ /')"
echo -e "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
}


#=======================================
# CARTRIDGE TO BE RECYCLED
#=======================================
tina_cartridges(){

# Cartridge to recyle for the next mount

echo -e "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ CARTRIDGE TO BE RECYCLED"
echo -e "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ Number of cartridge(s): $(${TiNa_PATH_INSTALL}tina_cart_control -list -v_name -v_location -v_recyclable -v_recycle_age -v_status -v_close_status -status_filter recyclable | grep 'Recyclable since' | wc -l)"
echo -e "┃-------------------------------------------------------------------"
echo -e "┃ Listing:"
echo -e "$(${TiNa_PATH_INSTALL}tina_cart_control -list -v_name -v_location -v_recyclable -v_recycle_age -v_status -v_close_status -status_filter recyclable | grep 'Recyclable since' | sed 's/^/┃ /')"
echo -e "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
}

#=======================================
# TiNa Agent Check
#=======================================

tina_agent_check(){

HOST_LST=(
"PROD1-SERV-0042.my.company.org"
"DEV1X-SERV-1042.my.company.org"
"PROD2-SERV-2042.my.company.org"
"DEV2X-SERV-3042.my.company.org"
)

echo -e "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ CHECKING IF TINA AGENT IS RUNNING"
echo -e "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃-------------------------------------------------------------------"
echo -e "┃ TiNa agent is running"
echo -e "┃-------------------------------------------------------------------"
for host in "${HOST_LST[@]}"; do
output=$(${TiNa_PATH_INSTALL}tina_ping -host "$host" | grep 'is running')
if [ -n "$output" ]; then
echo -e "┃ $output"
fi
done
echo -e "┃-------------------------------------------------------------------"
echo -e "┃ TiNa agent is NOT running"
echo -e "┃-------------------------------------------------------------------"
for host in "${HOST_LST[@]}"; do
output=$(${TiNa_PATH_INSTALL}tina_ping -host "$host" | grep 'is not running')
if [ -n "$output" ]; then
echo -e "┃ $output"
fi
done
echo -e "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

echo -e "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "┃ OTHER PROBLEMS"
echo -e "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
for host in "${HOST_LST[@]}"; do
output=$(${TiNa_PATH_INSTALL}tina_ping -host "$host" | grep -v 'running')
if [ -n "$output" ]; then
echo -e "┃ $output"
fi

done
echo -e "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

}

#========================================
# Main Program
#========================================
tina_host_summary
tina_list_host
tina_agent_check
backup_catalog_size
tina_cartridges

Documentation

Man TiNa
Man bash

🡅 Partager