Izan lecina webㅤㅤ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎  

ChatBot Flotante
ChatBot

Restauracio de backups

Per restaurar els backups generats tenim aquest script que comprova l’integritat dels backups abans de aplicar-los per a que no trenquin el sistema.Es important que l’hi doneu permisos d’execució

#!/bin/bash

# --- VARIABLES ---
DIR_BACKUPS="/media/ilecina/pen"
DESTINATION_RESTORATION="/"

#1. LLISTA DE CÒPIES DE SEGURIDAD DISPONIBLES
echo "--- Còpies de seguretat disponibles ---"
ls -lh $DIR_BACKUPS/*.tar.gz
echo "--------------------------"

#2. PREGUNTAR A L'USUARI QUÈ HA DE RESTAURAR
llegir -p "Introduïu el nom del fitxer a restaurar : " FITXER
COMPLETE_PATH="$BACKUPS_DIR/$FILE"

#3. CONTROLS DE SEGURETAT
if [ ! -f "$COMPLETE_PATH" ]; then
    echo "ERROR: El fitxer $COMPLETE_PATH no existeix."
    exit 1
fi

echo "Verificant la integritat del fitxer (això pot trigar una estona)."
# Redirigim la sortida a /dev/null perquè només ens importa si falla o no
tar -tzf "$COMPLETE_PATH" > /dev/null


if [ $? -ne 0]; then
    echo "El fitxer de còpia de seguretat està CORRUPT. I/O no es pot restaurar."
    exit 2
else
    echo "Integritat correcta".
fi

#4. RESTAURACIÓ REIAL
echo "S'estan restaurant fitxers a $DESTINO_RESTAURACION..."
tar -xzpf "$COMPLETE_PATH" -C "$RESTORATION_DESTINATION"
echo "La restauració s'ha completat correctament."
GDPR Cookie Consent with Real Cookie Banner