Fail2ban log; Rsync flow

This commit is contained in:
gospodar 2023-02-10 16:51:49 +01:00
parent 02b59f9e2b
commit 55aac75163
2 changed files with 22 additions and 10 deletions

View File

@ -16,13 +16,16 @@ log_backup=false # backup logs
log_backup_web=false # backup webapp logs log_backup_web=false # backup webapp logs
apache=false # apache log backup apache=false # apache log backup
nginx=false # nginx log backup nginx=false # nginx log backup
fail2ban_log=false # fail2ban log backup
log_purge=false # purge logs after backup log_purge=false # purge logs after backup
rsync_push=false # enable push to remote server rsync_push=false # enable push to remote server
push_clean=false # clean backup file after push push_clean=false # clean backup file after push
target_host="127.0.0.1" # rsync target host
target_user="backup" # rsync target user
target_key='/home/xyz/.ssh/rsync' # rsync key
#Docker #Docker
#Docker volumes #Docker volumes
#Syslogs
#Rsync #Rsync
#Daily cron #Daily cron
#Mysql dbs #Mysql dbs

27
main.sh
View File

@ -52,27 +52,36 @@ if [ "$log_backup" = true ] then
mkdir -p $tmpdir/syslogs mkdir -p $tmpdir/syslogs
cp /var/log/syslog $tmpdir/syslogs/ cp /var/log/syslog $tmpdir/syslogs/
cp /var/log/message $tmpdir/syslogs/ cp /var/log/message $tmpdir/syslogs/
if [ "$fail2ban_log" = true ] then
cp /var/log/fail2ban.log $tmpdir/syslogs/
fi
if [ "$log_backup_web" = true] then if [ "$log_backup_web" = true] then
if [ "$apache" = true ] then if [ "$apache" = true ] then
mkdir -p $tmpdir/apachelogs mkdir -p $tmpdir/apachelogs
cp -r /var/log/httpd $tmpdir/apachelogs cp -r /var/log/httpd $tmpdir/apachelogs
fi fi
if [ "$nginx" = true ] then if [ "$nginx" = true ] then
mkdir -p $tmpdir/nginxlogs mkdir -p $tmpdir/nginxlogs
cp -r /var/log/nginx $tmpdir/nginxlogs cp -r /var/log/nginx $tmpdir/nginxlogs
fi fi
fi fi
if [ "$log_purge" = true] then if [ "$log_purge" = true] then
echo "Purging logs..." >&2 echo "Purging logs..." >&2
truncate -s 0 /var/log/syslog truncate -s 0 /var/log/syslog
truncate -s 0 /var/log/message truncate -s 0 /var/log/message
if [ "$apache" = true ] then if [ "$apache" = true ] then
# TODO: removal for .1.2.3 logs # TODO: removal for .1.2.3 logs
truncate -s 0 /var/log/httpd/* truncate -s 0 /var/log/httpd/*
fi fi
if [ "$nginx" = true ] then if [ "$nginx" = true ] then
# TODO: removal for .1.2.3 logs # TODO: removal for .1.2.3 logs
truncate -s 0 /var/log/nginx/* truncate -s 0 /var/log/nginx/*
fi
if [ "$fail2ban_log" = true ] then
truncate -s 0 /var/log/fail2ban.log
fi fi
fi fi
echo "Finished" >&2 echo "Finished" >&2
@ -81,7 +90,7 @@ fi
function push { function push {
if [ "rsync_push" = true ] then if [ "rsync_push" = true ] then
#Push #Push - Dockerized
if [ "push_clean" = true ] then if [ "push_clean" = true ] then
rm /opt/backify-$timestamp.tar.gz rm /opt/backify-$timestamp.tar.gz
fi fi