Reputation: 126
I want to export the SQL Database into a GCS Bucket. For this purpose, I am using the following command of gcloud
:
gcloud sql export sql mybucket-dev-soft-db-instance-78f169a gs://mybucket-dev-app-soft-4e959a1/dump/sqldumpfile.gz --database=abc --parallel
But at the end it is creating sqldumpfile.gz
folder inside the dump
folder. I was expecting it as a .gz
file.
I have also tried it with .sql
extension but the result is same and instead of creating a single file, it creates the folder and inside that folder there are multiple file.
The issue is when I try to import this file in GCP Console
-->SQL Instance
-->Import
then it is expecting a single file and I am getting multiple file in the folder sqldumpfile.gz
or sqldumpfile.sql
.
This command is also documented in the official GCP documentation.
Could anybody tell me that what am I doing wrong ?
Upvotes: 0
Views: 65
Reputation: 413
It appears you're attempting a parallel export using the --parallel
flag to export SQL database to GCS bucket. However, parallel export is only supported or applicable for MySQL and PostgreSQL (see this documentation). This could be the reason you're not achieving the results you expect. Also, as stated here, exporting from Cloud SQL to a SQL dump file is not supported for SQL server.
For the equivalent SQL Server functionality, you can try to consider using the Striped BAK import/ export command or BAK files. For best practices, see Best Practices for Importing and Exporting Data for SQL server.
Upvotes: 0
Reputation: 749
Your confusion is because the export generates a folder with some files, not a Gzip file (*.gz) as you would expect.
So perform the below test.
gcloud sql export sql mybucket-dev-soft-db-instance-78f169a gs://mybucket-dev-app-soft-4e959a1/sqldumpfile --database=abc --parallel
Then run the below command to see the new folder's content.
gsutil ls gs://mybucket-dev-app-soft-4e959a1/sqldumpfile
You will get a response like the one below.
gs://mybucket-dev-app-soft-4e959a1/sqldumpfile/@.done.json
gs://mybucket-dev-app-soft-4e959a1/sqldumpfile/@.json
gs://mybucket-dev-app-soft-4e959a1/sqldumpfile/@.post.sql
gs://mybucket-dev-app-soft-4e959a1/sqldumpfile/@.sql
gs://mybucket-dev-app-soft-4e959a1/sqldumpfile/abc.json
gs://mybucket-dev-app-soft-4e959a1/sqldumpfile/abc.sql
The file that you need to perform the import is the abc.sql
all of the other files contain different information that for now is not relevant to your backup/restore process.
GCP Console-->SQL Instance-->Import->abc.sql (Browse it from the bucket is easier).
Upvotes: 0