Move database copying into its own function in main migration script

Small change to make the main migration script a bit more organized.