2022-05-14 03:18:52 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# logdest debe ser la misma ruta especificada en config.cfg como *ruta_base*
|
2022-05-29 00:04:49 -04:00
|
|
|
logdest=/home/$USER/nginx_log.old
|
2022-05-14 03:18:52 -04:00
|
|
|
|
2022-05-29 00:04:49 -04:00
|
|
|
serv_user="${USER}"
|
2022-05-14 03:18:52 -04:00
|
|
|
logdir=/var/log/nginx
|
|
|
|
|
2022-05-29 00:04:49 -04:00
|
|
|
mkdir $logdest 2>/dev/null
|
|
|
|
|
2022-05-14 03:18:52 -04:00
|
|
|
mueve_loggz(){
|
|
|
|
if [[ "$(ls $logdir/*.log.*.gz 2>/dev/null)" ]]; then
|
|
|
|
printf 'Moviendo logs.gz de %s/\n' "${logdir}"
|
|
|
|
sudo mv $logdir/*.log.*.gz $logdest
|
|
|
|
sudo chown $serv_user:$serv_user $logdest/*
|
|
|
|
else
|
|
|
|
printf 'No hay logs archivados para mover\n'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$(ls $logdest/*.gz 2>/dev/null)" ]]; then
|
|
|
|
printf 'Existen logs pendientes de respaldo\n'
|
|
|
|
else
|
|
|
|
mueve_loggz
|
|
|
|
fi
|
|
|
|
exit 0
|