Refactoring and improving backup scripts