bash_-_script_synchronisation_wiki
Ceci est une ancienne révision du document !
BASH - Script Synchronisation WIKI
Ce script permet de copier l’intégralité du WIKI sur une clé USB
RSYNC permet de copier des fichiers dans une autre destination.
Il vérifie la dernière modification des fichiers et transferts que se qu'il ont été modifier.
#!/bin/bash rsync -rltzuv /var/www/* /media/usb0/backup/ echo "Synchro faite le $(date)" >> /media/usb0/backup/LOG.txt echo "========================" >> /media/usb0/backup/LOG.txt
Il est ensuite exécuter tout les jours a 3h30 du matin, et il inscrit un message dans le fichier LOG.txt dans la clef.
Modification du script le 18/09/2016
#!/bin/bash REPERTOIRE_SOURCE="/var/www/" REPERTOIRE_DESTINATION="/home/user/partage/" DATE=$(date) # Détecter la présence du volume de destination et interrompre l'opération si nécessaire rm "$REPERTOIRE_DESTINATION"*.log if [ "$(ls -A $REPERTOIRE_DESTINATION)" ] then rsync -av "$REPERTOIRE_SOURCE" "$REPERTOIRE_DESTINATION" >> "$REPERTOIRE_DESTINATION""$DATE".log else echo "Le partage n'est pas monté, check le NFS de SAUVEGARDE" >> "$REPERTOIRE_DESTINATION""$DATE".error.log fi
Attention, ceci est un test.
#!/bin/bash REPERTOIRE_SOURCE="/var/www/" REPERTOIRE_DESTINATION="/root/BACKUP" DATE=$(date) # Détecter la présence du volume de destination et interrompre l'opération si nécessaire #rm "$REPERTOIRE_DESTINATION"*.log rsync -av "$REPERTOIRE_SOURCE" "$REPERTOIRE_DESTINATION""/Fichiers/" >> "$REPERTOIRE_DESTINATION""/logs/""fichiers_""$DATE".log # Compression en TAR de tous les éléments tar -zcvf "$REPERTOIRE_DESTINATION""/Compress/""$DATE".tar.gz "$REPERTOIRE_DESTINATION""/Fichiers/" >>"$REPERTOIRE_DESTINATION""/logs/""tar_""$DATE".log # Cryptage du fichier TAR en gpg gpg -c --passphrase "Password17" -o "$REPERTOIRE_DESTINATION""/Crypt/""$DATE".gpg "$REPERTOIRE_DESTINATION""/Compress/""$DATE".tar.gz >> "$REPERTOIRE_DESTINATION""/logs/""crypt_""$DATE".log
bash_-_script_synchronisation_wiki.1479978883.txt.gz · Dernière modification : (modification externe)