Documentation, alternatives.log kickout

This commit is contained in:
gospodar 2023-02-22 18:09:48 +01:00
parent 65b5b20b18
commit 6dcc7eb8e0
3 changed files with 20 additions and 19 deletions

View File

@ -30,7 +30,7 @@ All configuration options can be found in the `backup.cfg` file. The script has
| vhost_backup | true/false | Backup of the vhost configuration | | vhost_backup | true/false | Backup of the vhost configuration |
| vhost_dir | ------> | Path to the vhost files | | vhost_dir | ------> | Path to the vhost files |
| log_backup | true/false | Backup log files | | log_backup | true/false | Backup log files |
| log_to_backup |array | Array of logs to backup, options: apache, nginx, fail2ban, alternatives, pckg_mngr, auth, dmesg, dpkg, letsencrypt, php, syslog, purge (truncate all)| | log_to_backup |array | Array of logs to backup, see below for options|
| rsync_push | true/false | Push the backup file to a remote server | | rsync_push | true/false | Push the backup file to a remote server |
| push_clean | true/false | Delete the backup file after push | | push_clean | true/false | Delete the backup file after push |
| target_host | ------> | Backup push target host | | target_host | ------> | Backup push target host |
@ -49,6 +49,23 @@ All configuration options can be found in the `backup.cfg` file. The script has
| db_all | ------> | Dump all databases instead of specific one | | db_all | ------> | Dump all databases instead of specific one |
## Logs to backup array 📚
| Option | Specifics |
| apache | Apache access and error logs |
| nginx | Nginx access and error logs |
| fail2ban | Fail2ban log |
| alternatives | Alternatives log |
| pckg_mngr | Logs from Yum/Apt package manager |
| auth | Authentications log |
| dmesg | Kernel log |
| dpkg | Package changes log |
| letsencrypt | Let's encrypt logs |
| php | Logs from all installed PHPs |
| syslog | System event data |
| purge | Empty all the logs after backing up |
## Script Execution 🪄 ## Script Execution 🪄

View File

@ -9,8 +9,8 @@ www_dir='xyz' # wwwroot location
vhost_backup=false # backup vhost config vhost_backup=false # backup vhost config
vhost_dir='/etc/httpd/sites-enabled' # vhost location vhost_dir='/etc/httpd/sites-enabled' # vhost location
log_backup=false # backup logs log_backup=false # backup logs
log_to_backup=("apache" "nginx" "fail2ban" "alternatives" "pckg_mngr" "auth" "dmesg" "dpkg" "letsencrypt" "php" "syslog" "purge") log_to_backup=("apache" "nginx" "fail2ban" "pckg_mngr" "auth" "dmesg" "dpkg" "letsencrypt" "php" "syslog" "purge")
# logs to backup, options: apache, nginx, fail2ban, alternatives, pckg_mngr, auth, dmesg, dpkg, letsencrypt, php, syslog, purge (truncate all)) # logs to backup, options: apache, nginx, fail2ban, pckg_mngr, auth, dmesg, dpkg, letsencrypt, php, syslog, purge (truncate all))
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_host="127.0.0.1" # rsync target host

16
main.sh
View File

@ -89,11 +89,6 @@ function logbackup {
cp -r /var/log/nginx "$tmpdir/nginxlogs" cp -r /var/log/nginx "$tmpdir/nginxlogs"
fi fi
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[alternatives]} " ]]; then
mkdir -p "$tmpdir/syslogs/"
cp -r /var/log/alternatives.log "$tmpdir/syslogs/"
fi
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[pckg_mngr]} " ]]; then if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[pckg_mngr]} " ]]; then
mkdir -p "$tmpdir/syslogs/" mkdir -p "$tmpdir/syslogs/"
mkdir -p "$tmpdir/syslogs/yum" mkdir -p "$tmpdir/syslogs/yum"
@ -146,9 +141,6 @@ function logbackup {
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[fail2ban]} " ]]; then if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[fail2ban]} " ]]; then
truncate -s 0 /var/log/fail2ban.log truncate -s 0 /var/log/fail2ban.log
fi fi
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[alternatives]} " ]]; then
truncate -s 0 /var/log/alternatives.log
fi
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[pckg_mngr]} " ]]; then if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[pckg_mngr]} " ]]; then
truncate -s 0 /var/log/yum/* truncate -s 0 /var/log/yum/*
fi fi
@ -189,11 +181,6 @@ function logbackup {
cp -r /var/log/nginx "$tmpdir/nginxlogs" cp -r /var/log/nginx "$tmpdir/nginxlogs"
fi fi
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[alternatives]} " ]]; then
mkdir -p "$tmpdir/syslogs/"
cp -r /var/log/alternatives.log "$tmpdir/syslogs/"
fi
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[pckg_mngr]} " ]]; then if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[pckg_mngr]} " ]]; then
mkdir -p "$tmpdir/syslogs/" mkdir -p "$tmpdir/syslogs/"
mkdir -p "$tmpdir/syslogs/apt" mkdir -p "$tmpdir/syslogs/apt"
@ -246,9 +233,6 @@ function logbackup {
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[fail2ban]} " ]]; then if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[fail2ban]} " ]]; then
truncate -s 0 /var/log/fail2ban.log truncate -s 0 /var/log/fail2ban.log
fi fi
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[alternatives]} " ]]; then
truncate -s 0 /var/log/alternatives.log
fi
if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[pckg_mngr]} " ]]; then if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[pckg_mngr]} " ]]; then
truncate -s 0 /var/log/apt/* truncate -s 0 /var/log/apt/*
fi fi