Added sanity checks after upgrading the data format

- Makes a backup file during the upgrade
- Verifies the size and existance of a file in writeData
- Verifies that the written file can be read after upgrading
Split data upgrades into its own subroutine