8343-New-machine-id #48

Merged
xavi merged 40 commits from 8343-New-machine-id into main 2025-01-10 13:29:15 +00:00
1 changed files with 12 additions and 7 deletions
Showing only changes of commit 85680e4c50 - Show all commits

View File

@ -45,6 +45,10 @@ show_help() {
exit 0 exit 0
} }
exit_from_repo() {
proxmox-backup-client logout --repository "$IP_MACHINE:$POOL" 2>>"$LOG_FILE" && echo "$(date '+%Y-%m-%d %H:%M:%S') - Logged out from repository $IP_MACHINE:$POOL" | tee -a "$LOG_FILE"
}
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
--standard) --standard)
@ -69,7 +73,7 @@ while [[ $# -gt 0 ]]; do
show_help show_help
;; ;;
*) *)
echo "Error: Opción no reconocida '$1'" echo "Error: Unrecognized option '$1'"
show_help show_help
;; ;;
esac esac
@ -77,19 +81,18 @@ while [[ $# -gt 0 ]]; do
done done
if [ -z "$MODE" ]; then if [ -z "$MODE" ]; then
echo "Error: Debes especificar --standard o --encrypt." echo "You must specify --standard or --encrypt."
show_help show_help
fi fi
echo "$(date '+%Y-%m-%d %H:%M:%S') - Iniciando respaldo al repositorio $IP_MACHINE:$POOL" | tee -a "$LOG_FILE" echo "$(date '+%Y-%m-%d %H:%M:%S') - Starting backup to repository $IP_MACHINE:$POOL" | tee -a "$LOG_FILE"
for item in $(echo "$BACKUP_ITEMS" | tr ',' '\n'); do for item in $(echo "$BACKUP_ITEMS" | tr ',' '\n'); do
BACKUP_NAME=$(echo "$item" | cut -d':' -f1) BACKUP_NAME=$(echo "$item" | cut -d':' -f1)
TARGET_DIR=$(echo "$item" | cut -d':' -f2) TARGET_DIR=$(echo "$item" | cut -d':' -f2)
if [ "$MODE" == "encrypt" ]; then if [ "$MODE" == "encrypt" ]; then
# Comprobar si el archivo de clave existe
if [ ! -f "$KEY_FILE" ]; then if [ ! -f "$KEY_FILE" ]; then
echo "Error: El archivo de clave $KEY_FILE no existe." | tee -a "$LOG_FILE" echo "The key file $KEY_FILE does not exist." | tee -a "$LOG_FILE"
exit 1 exit 1
fi fi
@ -100,8 +103,10 @@ else
done done
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -e "$(date '+%Y-%m-%d %H:%M:%S') - Respaldo completado con éxito. Puede revisar el log en $LOG_FILE\n" | tee -a "$LOG_FILE" exit_from_repo
echo -e "$(date '+%Y-%m-%d %H:%M:%S') - Backup completed successfully. You can check the log at $LOG_FILE\n" | tee -a "$LOG_FILE"
else else
echo -e "$(date '+%Y-%m-%d %H:%M:%S') - Error durante el respaldo. Puede revisar el log en $LOG_FILE\n" | tee -a "$LOG_FILE" exit_from_repo
echo -e "$(date '+%Y-%m-%d %H:%M:%S') - Error during backup. You can check the log at $LOG_FILE\n" | tee -a "$LOG_FILE"
exit 1 exit 1
fi fi