-
-
Save samuelloza/504d41f106d9f7c656ed4dbdc55ea15b to your computer and use it in GitHub Desktop.
Backup data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Script para hacer la copia de seguridad desde 192.168.188.5 a | |
| # 192.168.188.4 (servidor espejo) | |
| function loginfo(){ | |
| myUser="rsync" | |
| logger -p user.info "${myUser}[$$]: $1" | |
| } | |
| function logerror(){ | |
| myUser="rsync" | |
| logger -p user.err "${myUser}[$$]: $1" | |
| } | |
| # Declaración de variables | |
| DATA="/var/www/" | |
| HOST_DEST="[email protected]" | |
| LOGFILE="/tmp/rsyncData-$(date +%Y-%m-%d).log" | |
| ERRORLOG="/tmp/error-rsyncData-$(date +%Y-%m-%d).log" | |
| # Se realiza la sincronizacion | |
| rsync -aAvz -q --log-file=$LOGFILE $DATA/* $HOST_DEST:$DATA/ 2> $ERRORLOG | |
| # Se valida que todo haya salido bien | |
| if [ $? -eq 0 ]; then | |
| loginfo "La sincronización desde \"$DATA\" (localhost) al directorio \"$DATA\" (192.168.188.4) se ha realizado con EXITO." | |
| echo "La sincronización desde \"$DATA\" (localhost) al directorio \"$DATA\" (192.168.188.4) se ha realizado con EXITO." | |
| else | |
| logerror "Ha habido un ERROR, no se ha podido realizar la sincronización desde \"$DATA_DEST\" (localhost) al directorio \"$DATA\" (192.168.188.4), revise el log en \"$ERRORLOG\"" | |
| echo "Ha habido un ERROR, no se ha podido realizar la sincronización desde \"$DATA\" (localhost) al directorio \"$DATA_DEST\" (192.168.188.4), revise el log en \"$ERRORLOG\"" | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment