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