diff --git a/README.MD b/README.MD index e0e21af..0504841 100644 --- a/README.MD +++ b/README.MD @@ -40,11 +40,11 @@ All configuration options can be found in the `backup.cfg` file. The script has | db_username | ------> | Username for DB access | | db_password | ------> | Password for DB access | | db_name | ------> | Name of database | +| db_all | ------> | Dumb all databases instead of specific one | To-Do List ---------- - [ ] Rsync implementation via shell - [ ] Rsync implementation via Docker -- [ ] Cron scheduler -- [ ] Refactor system logs \ No newline at end of file +- [ ] Cron scheduler \ No newline at end of file diff --git a/main.sh b/main.sh index e281bfc..06fc8cc 100644 --- a/main.sh +++ b/main.sh @@ -89,7 +89,7 @@ function logbackup { cp /var/log/fail2ban.log $tmpdir/syslogs/ fi - if [ "$log_backup_web" = true] + if [ "$log_backup_web" = true ] then if [ "$apache" = true ] then @@ -103,7 +103,7 @@ function logbackup { fi fi - if [ "$log_purge" = true] + if [ "$log_purge" = true ] then echo "Purging logs..." >&2 truncate -s 0 /var/log/syslog @@ -125,7 +125,7 @@ function logbackup { fi ;; - "ubuntu") + "ubuntu") cp /var/log/syslog $tmpdir/syslogs/ cp /var/log/message $tmpdir/syslogs/ @@ -134,7 +134,7 @@ function logbackup { cp /var/log/fail2ban.log $tmpdir/syslogs/ fi - if [ "$log_backup_web" = true] + if [ "$log_backup_web" = true ] then if [ "$apache" = true ] then @@ -148,34 +148,35 @@ function logbackup { fi fi - if [ "$log_purge" = true] - then - echo "Purging logs..." >&2 - truncate -s 0 /var/log/syslog - truncate -s 0 /var/log/message + if [ "$log_purge" = true ] + then + echo "Purging logs..." >&2 + truncate -s 0 /var/log/syslog + truncate -s 0 /var/log/message if [ "$apache" = true ] - then + then truncate -s 0 /var/log/apache2/* rm /var/log/apache2/*.gz - fi + fi if [ "$nginx" = true ] - then + then truncate -s 0 /var/log/nginx/* rm /var/log/nginx/*.gz - fi - if [ "$fail2ban_log" = true ] - then + fi + if [ "$fail2ban_log" = true ] + then truncate -s 0 /var/log/fail2ban.log + fi fi - fi - + esac +fi } function push { if [ "$rsync_push" = true ] then #Push - Dockerized - if [ "push_clean" = true ] + if [ "$push_clean" = true ] then rm /opt/backify-$timestamp.tar.gz fi @@ -201,6 +202,7 @@ function dockerbackup { if [ "$docker_volumes" = true ] then echo "Backing up Docker volumes..." >&2 + #Thanks piscue :) for i in `docker inspect --format='{{.Name}}' $(docker ps -q) | cut -f2 -d\/` do container_name=$i mkdir -p $tmpdir/containers/$container_name @@ -247,6 +249,7 @@ function backup_db { then pg_dump -U "$db_username" "$db_name" -f $tmpdir/db/$db_name.sql fi + fi } function runbackup { @@ -263,14 +266,7 @@ function runbackup { # step 3 : vhost backup vhostbackup # step 4: log backup - if [ $system = "rhel" ] - then - logbackuprhel - fi - if [ $system = "ubuntu" ] - then - logbackupubuntu - fi + logbackup # step 5: docker backup dockerbackup # step 6: db backup