Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup of logfile only if backup was created successfully #1327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions TeslaLogger/bin/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ if [ $DAY -eq 1 ]; then
MONTH=$(date +%m)
YEAR=$(date +%Y)
LYEAR=$((YEAR-1))
#echo processing logfile backup
cp /etc/teslalogger/nohup.out /etc/teslalogger/logfile-$YEAR$MONTH.log
gzip -c9 /etc/teslalogger/logfile-*.log > /etc/teslalogger/backup/logfile-$YEAR$MONTH.gz
if test -f "/etc/teslalogger/backup/logfile-$YEAR$MONTH.gz"; then
rm /etc/teslalogger/logfile-*.log
fi
echo > /etc/teslalogger/nohup.out
#echo processing logfile backup and cleaning of logfile only if backup of this month does not already exist
if ! test -f "/etc/teslalogger/backup/logfile-$YEAR$MONTH.gz"; then
cp /etc/teslalogger/nohup.out /etc/teslalogger/logfile-$YEAR$MONTH.log
gzip -c9 /etc/teslalogger/logfile-*.log > /etc/teslalogger/backup/logfile-$YEAR$MONTH.gz
if test -f "/etc/teslalogger/backup/logfile-$YEAR$MONTH.gz"; then
rm /etc/teslalogger/logfile-*.log
echo > /etc/teslalogger/nohup.out
fi
fi

#echo processing cleanup of files older than $LYEAR$MONTH*
if test -f "/etc/teslalogger/backup/logfile-$LYEAR$MONTH.gz"; then
Expand All @@ -40,7 +42,7 @@ if [ $DAY -eq 1 ]; then
if test -f "/etc/teslalogger/backup/mysqldump$LYEAR$MONTH*.gz"; then
rm /etc/teslalogger/backup/mysqldump$LYEAR$MONTH*.gz
fi
if test -f "\\teslalogger\teslalogger\Exception\ex_$LYEAR$MONTH*.gz"; then
if test -f "\\teslalogger\teslalogger\Exception\ex_$LYEAR$MONTH*.gz"; then
rm \\teslalogger\teslalogger\Exception\ex_$LYEAR$MONTH*.gz
fi
fi
Expand Down
Loading