diff --git a/README.MD b/README.MD index b3420e5..bc7d385 100644 --- a/README.MD +++ b/README.MD @@ -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_dir | ------> | Path to the vhost 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 | | push_clean | true/false | Delete the backup file after push | | 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 | +## 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 🪄 diff --git a/backup.cfg b/backup.cfg index 34744c5..65b2fa1 100644 --- a/backup.cfg +++ b/backup.cfg @@ -9,8 +9,8 @@ www_dir='xyz' # wwwroot location vhost_backup=false # backup vhost config vhost_dir='/etc/httpd/sites-enabled' # vhost location log_backup=false # backup logs -log_to_backup=("apache" "nginx" "fail2ban" "alternatives" "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)) +log_to_backup=("apache" "nginx" "fail2ban" "pckg_mngr" "auth" "dmesg" "dpkg" "letsencrypt" "php" "syslog" "purge") +# 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 push_clean=false # clean backup file after push target_host="127.0.0.1" # rsync target host diff --git a/main.sh b/main.sh index c742b9c..bb45056 100644 --- a/main.sh +++ b/main.sh @@ -89,11 +89,6 @@ function logbackup { cp -r /var/log/nginx "$tmpdir/nginxlogs" 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 mkdir -p "$tmpdir/syslogs/" mkdir -p "$tmpdir/syslogs/yum" @@ -146,9 +141,6 @@ function logbackup { if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[fail2ban]} " ]]; then truncate -s 0 /var/log/fail2ban.log 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 truncate -s 0 /var/log/yum/* fi @@ -189,11 +181,6 @@ function logbackup { cp -r /var/log/nginx "$tmpdir/nginxlogs" 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 mkdir -p "$tmpdir/syslogs/" mkdir -p "$tmpdir/syslogs/apt" @@ -246,9 +233,6 @@ function logbackup { if [[ " ${log_to_backup[*]} " =~ " ${log_to_backup[fail2ban]} " ]]; then truncate -s 0 /var/log/fail2ban.log 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 truncate -s 0 /var/log/apt/* fi