NAUbackup / VmBackup

XenServer simple backup script
228 stars 61 forks source link

No log file produced #42

Open ilium007 opened 7 years ago

ilium007 commented 7 years ago

I started looking through the script to try and work out why emails aren't being sent. The email code by itself works fine, so I looked further and realised no log file is being written. I can't figure out why though.

Path to DEFAULT_STATUS_LOG exists and is writable.

status_log = config['status_log'] is correctly assigned - the file is simply not being written.

This block should be the first place where the log file is written to:

def status_log_begin(server): rec_begin = '%s,vmbackup.py,%s,begin\n' % (fmtDateTime(), server) open(config['status_log'],'a',0).write(rec_begin)

But when I run this function in a python shell it all works fine - log file is written

ilium007 commented 7 years ago

Found it.

There is a if statement that stops the log file being written:

if (os.path.exists(cfg_file)):

config file exists

config_specified = 1

which causes the log to never be written:

if config_specified: status_log_begin(server_name)

So.. to get a log file you have to be using a seperate config file and therefore to get emails sent you have to be using a config file. It's too late tonight for me to be submit a fix.

I don't understand why the external config file is the trigger as to whether we write a log file or not.