67 lines
2.1 KiB
Bash
67 lines
2.1 KiB
Bash
#!/bin/sh
|
|
# Ce script exporte la configuration Nginx Proxy Manager
|
|
# Derniere modification : 26.05.2026 - S. SIMON
|
|
|
|
# Initialisation d'une variable d'erreur
|
|
ERROR_VAR="0"
|
|
|
|
# Initialisation des variables
|
|
DATETIME=$(date +%Y%m%d-%H%M)
|
|
SOURCE="/volume1/docker/npm"
|
|
DEST="/volume1/backup/npm"
|
|
|
|
# Initialisation du fichier de log
|
|
LOG_FILE=/volume1/backup/npm/exportnpm_`date +%Y%m%d`.log
|
|
if [ -e "$LOG_FILE" ]; then
|
|
echo $DATETIME \| INFO \| Le fichier de log existe deja >>$LOG_FILE 2>&1
|
|
else
|
|
touch $LOG_FILE
|
|
echo \|---------- >$LOG_FILE 2>&1
|
|
echo \|-- JOURNAL DU SCRIPT D\'EXPORT NPM >>$LOG_FILE 2>&1
|
|
echo \|---------- >>$LOG_FILE 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
echo $DATETIME \| INFO \| Le fichier de log a ete cree avec succes >>$LOG_FILE 2>&1
|
|
else
|
|
echo $DATETIME \| ERREUR \| Erreur lors de la creation du fichier de log >>$LOG_FILE 2>&1
|
|
ERROR_VAR=$(($ERROR_VAR +1))
|
|
fi
|
|
fi
|
|
|
|
# Suppression des fichiers de plus de 10 jours
|
|
echo -- >>$LOG_FILE 2>&1
|
|
echo $DATETIME \| INFO \| Suppression des fichiers de plus de 10 jours >>$LOG_FILE 2>&1
|
|
find /volume1/backup/npm -type f -mtime +10 -exec rm -rf {} + >>$LOG_FILE 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
echo $DATETIME \| INFO \| Suppression des anciens fichiers : OK >>$LOG_FILE 2>&1
|
|
else
|
|
echo $DATETIME \| ERREUR \| Erreur lors de la suppression des fichiers de plus de 10 jours >>$LOG_FILE 2>&1
|
|
ERROR_VAR=$(($ERROR_VAR +1))
|
|
fi
|
|
|
|
# EXPORT DE LA CONFIGURATION NPM
|
|
echo -- >>$LOG_FILE 2>&1
|
|
echo $DATETIME \| INFO \| Export de la configuration NPM >>$LOG_FILE 2>&1
|
|
|
|
command -v zip >/dev/null 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
echo "$DATETIME \| ERREUR \| Commande zip introuvable" >>$LOG_FILE
|
|
exit 1
|
|
fi
|
|
|
|
cd /volume1/docker || exit 1
|
|
|
|
zip -r "$DEST/npm-$(date +%Y%m%d_%H%M%S).zip" npm >>$LOG_FILE 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo $DATETIME \| INFO \| Export de la configuration NPM : OK >>$LOG_FILE 2>&1
|
|
else
|
|
echo $DATETIME \| ERREUR \| Erreur lors de l\'Export de la configuration NPM >>$LOG_FILE 2>&1
|
|
ERROR_VAR=$(($ERROR_VAR +1))
|
|
fi
|
|
|
|
# Fin du script
|
|
echo -- >>$LOG_FILE 2>&1
|
|
echo $DATETIME \| INFO \| Erreurs rencontrees : $ERROR_VAR >>$LOG_FILE 2>&1
|
|
echo -- >>$LOG_FILE 2>&1
|
|
|