Moved the code that determines the backup filename into a new function