Move database copying into its own function in main migration script