Skip to content

wusendong/spanner-dump

 
 

Repository files navigation

spanner-dump CircleCI

spanner-dump is a command line tool for exporting a Cloud Spanner database in text format.

Exported databases can be imported to Cloud Spanner with spanner-cli.

# Export
$ spanner-dump -p ${PROJECT} -i ${INSTANCE} -d ${DATABASE} > data.sql

# Import
$ spanner-cli -p ${PROJECT} -i ${INSTANCE} -d ${DATABASE} < data.sql

Please feel free to report issues and send pull requests, but note that this application is not officially supported as part of the Cloud Spanner product.

Use cases

This tool can be used for the following use cases.

For production databases, you should use an officially-provided export, which should be stable and much faster.

Limitations

  • This tool does not ensure consistency between database schema (DDL) and data. So you should avoid making changes to the schema while you are running this tool.
  • This tool does not consider data order constrained by Foreign Keys.

Install

go get -u github.com/cloudspannerecosystem/spanner-dump

Usage

Usage:
  spanner-dump [OPTIONS]

Application Options:
  -p, --project=   (required) GCP Project ID.
  -i, --instance=  (required) Cloud Spanner Instance ID.
  -d, --database=  (required) Cloud Spanner Database ID.
      --tables=    comma-separated table names, e.g. "table1,table2"
      --no-ddl     No DDL information.
      --timestamp= Timestamp for database snapshot in the RFC 3339 format.
      --bulk-size= Bulk size for values in a single INSERT statement.

Help Options:
  -h, --help       Show this help message

This tool uses Application Default Credentials to connect to Cloud Spanner. Please make sure to get credentials via gcloud auth application-default login before using this tool.

Also, you need to have a roles/spanner.databaseReader IAM role to use this tool.

Disclaimer

This tool is still ALPHA quality. Do not use this tool for production databases.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%