Log backup refactoring
This commit is contained in:
parent
5183b9bc7d
commit
0478ce746a
@ -47,5 +47,4 @@ To-Do List
|
|||||||
- [ ] Rsync implementation via shell
|
- [ ] Rsync implementation via shell
|
||||||
- [ ] Rsync implementation via Docker
|
- [ ] Rsync implementation via Docker
|
||||||
- [ ] Cron scheduler
|
- [ ] Cron scheduler
|
||||||
- [ ] PostgreSQL backups
|
- [ ] Refactor system logs
|
||||||
- [ ] Cover more system logs
|
|
24
main.sh
24
main.sh
@ -4,7 +4,7 @@ function init {
|
|||||||
echo "Backify is starting, looking for configuration file..." >&2
|
echo "Backify is starting, looking for configuration file..." >&2
|
||||||
|
|
||||||
config='backup.cfg'
|
config='backup.cfg'
|
||||||
config_secured='sbackup.cfg'
|
secured_config='sbackup.cfg'
|
||||||
|
|
||||||
if [ ! -f "$config" ]
|
if [ ! -f "$config" ]
|
||||||
then
|
then
|
||||||
@ -15,8 +15,8 @@ fi
|
|||||||
|
|
||||||
if grep -E -q -v '^#|^[^ ]*=[^;]*' "$config"; then
|
if grep -E -q -v '^#|^[^ ]*=[^;]*' "$config"; then
|
||||||
echo "Config file is unclean, cleaning it..." >&2
|
echo "Config file is unclean, cleaning it..." >&2
|
||||||
grep -E '^#|^[^ ]*=[^;&]*' "$config" > "$config_secured"
|
grep -E '^#|^[^ ]*=[^;&]*' "$config" > "$secured_config"
|
||||||
config="$config_secured"
|
config="$secured_config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source "$config"
|
source "$config"
|
||||||
@ -73,11 +73,14 @@ then
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function logbackupcentos {
|
function logbackup {
|
||||||
if [ "$log_backup" = true ]
|
if [ "$log_backup" = true ]
|
||||||
then
|
then
|
||||||
echo "Backing up system logs..." >&2
|
echo "Backing up system logs..." >&2
|
||||||
mkdir -p $tmpdir/syslogs
|
mkdir -p $tmpdir/syslogs
|
||||||
|
|
||||||
|
case $system in
|
||||||
|
"rhel")
|
||||||
cp /var/log/syslog $tmpdir/syslogs/
|
cp /var/log/syslog $tmpdir/syslogs/
|
||||||
cp /var/log/message $tmpdir/syslogs/
|
cp /var/log/message $tmpdir/syslogs/
|
||||||
|
|
||||||
@ -120,15 +123,9 @@ then
|
|||||||
truncate -s 0 /var/log/fail2ban.log
|
truncate -s 0 /var/log/fail2ban.log
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "Finished" >&2
|
;;
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function logbackupubuntu {
|
"ubuntu")
|
||||||
if [ "$log_backup" = true ]
|
|
||||||
then
|
|
||||||
echo "Backing up system logs..." >&2
|
|
||||||
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/
|
||||||
|
|
||||||
@ -171,8 +168,7 @@ then
|
|||||||
truncate -s 0 /var/log/fail2ban.log
|
truncate -s 0 /var/log/fail2ban.log
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "Finished" >&2
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function push {
|
function push {
|
||||||
|
Loading…
Reference in New Issue
Block a user