0
votes

Here is the restore code I ran:

gcloud sql backups restore 1588287600000 --restore-instance=newinstance \
                                          --backup-instance=backupinstance

I am trying to restore a cloud sql backup from another instance to a new instance I crreated but I end up with this error

(gcloud.sql.backups.restore) HTTPError 400: This operation isn"t valid for this instance.
1
Does the new instance have read replicas? I suggest you to read the Overview of restoring an instance documentation to see if your new instance can restore the backup - Chris32
Ok thanks @Chris32 your suggestion gave light to the solution. So basically i made sure the new instance has the same configurations as the backup instance in the process of creating I also set the root-password to none. Then the backup command finally worked - chukwuka mark

1 Answers

2
votes

So basically I made sure the new instance has the same configurations as the backup instance in the process of creatinge.g memory, storage-size, cpu and also set the root-password to none. more on restore requirments https://cloud.google.com/sql/docs/mysql/backup-recovery/restore#tips-restore

gcloud sql instances create $TARGET_INSTANCE_NAME --root-password="" --memory=$MEMORY"GB" --storage-size=$SIZE --cpu=$CPU --database-version="MYSQL_5_6" --zone=us-central1-a
# #
# # Restor backup from backup instance to new instance

#
 gcloud beta sql backups restore $BACKUP_ID --restore-instance=$TARGET_INSTANCE_NAME --backup-instance=$SOURCE_INSTANCE_NAME