How to automate data backup and restoration in Python?