// If requested to pre-populate database from a backup of previous/existing database // and updates clusterState with DB credentials func (bkr *Broker) prepopulateDatabaseFromExistingClusterData(existingClusterData *structs.ClusterRecreationData, toInstanceID structs.ClusterID, clusterModel *state.ClusterModel, logger lager.Logger) (err error) { if bkr.backups.BaseURI == "" { return fmt.Errorf("Failed to copy existing database backup: missing backups.base_uri configuration") } fromDatabaseBackup := fmt.Sprintf("%s/%s", bkr.backups.BaseURI, existingClusterData.InstanceID) toDatabaseBackup := fmt.Sprintf("%s/%s", bkr.backups.BaseURI, toInstanceID) err = bkr.callbacks.CopyDatabaseBackup(fromDatabaseBackup, toDatabaseBackup, bkr.logger) if err != nil { logger.Error("prepopulate-database", err) return fmt.Errorf("Failed to copy existing database backup to new database: %s", err.Error()) } return clusterModel.UpdateCredentials(existingClusterData) }