Additional error handling for copy_file (wallet backup), copied from Bitcoin source