rocky-linux/rocky-tools

migrate2rocky logfile is truncated on each start, all info lost when restarting

electroniceel opened this issue · 5 comments

I just had a migrate2rocky run fail due to an error with a package in a custom repo. Essentially the same as #112. I fixed the repo issue and then accidently ran migrate2rocky again. This removed all info from /var/log/migrate2rocky.log before logging that it can't continue. As I wanted to continue the migration manually, I was missing all the info about the previously installed modules that was in the logfile before.

Currently there is the call ```truncate -s0 "$logfile"```` at the beginning of migrate2rocky.sh. I suggest to replace that with adding a date/time marker to the logfile, so you can easily keep apart different runs.

Something like this:

echo "===============================================================================================" >>"$logfile"
date >>"$logfile"
echo "===============================================================================================" >>"$logfile"
echo >>"$logfile"

What do you think?

I think some sort of log rotation would be appropriate. Either add in a timestamp to the filename or a sequence number and rotate the logs so that up to five are kept before the oldest ones drop off.

Hmm, isn't a full rotation scheme a bit of overkill?

migrate2rocky isn't designed to be run regularly. Actually it won't work anymore once it passed a certain point. Once you finished migration, you won't run it again. So I don't think that the file getting too large over time is an issue.

So I wouldn't bother with rotating, just preserving the data that is in there.

The logs can be quite long as it is, so it makes more sense (imo) to have a separate log file for each run of the script just to avoid any individual log getting too long. Once we're doing separate log files it really isn't much of a stretch to do rotation and it is necessary to keep the files from taking up too much space. Also rotation is easy, should just be a few lines of code.

The logs can be quite long as it is

I just had a look at my migrate-logfiles. The largest one is just about 600 KBytes and 7000 lines. So in my perspective these logs are miniscule.

I wouldn't bother with rotation unless they regularly reach tens of megabytes and I don't see a way the migrate2rocky-logfiles will reach that size.

This is now fixed with PR #135