RESTORE DATABASE
On this page
Restores a database from a binary backup file.
Refer to Back Up and Restore Data for additional information.
Syntax
Restore From S3
RESTORE [DATABASE] <database_name> FROM S3 "bucket/path"[CONFIG <configuration_json>]CREDENTIALS <credentials_json>[WITH FILE = incr_backup_id][sync_options][(OPTION resource_pool = resource_pool_name)]<configuration_json>:'{"region":"your_region","endpoint_url":"http://other_endpoint"[, "x-amz-server-side-encryption-customer-algorithm":"<encryption_type>","x-amz-server-side-encryption-customer-key":"<encrypted_or_unencrypted_key>","x-amz-server-side-encryption-customer-key-MD5":"<key>"]}'<credentials_json>:'{"aws_access_key_id": "replace_with_your_access_key_id","aws_secret_access_key": "replace_with_your_secret_access_key",["aws_session_token": "replace_with_your_temp_session_token",]["role_arn":"replace_with_your_role_arn"]}'sync_options:WITH {SYNC | ASYNC} DURABILITY| WITH {SYNC | ASYNC} REPLICATION| WITH {SYNC | ASYNC} DURABILITY {SYNC | ASYNC} REPLICATION
Restore From an S3 Compatible Storage Provider
RESTORE [DATABASE] <database_name> [AS <new_db_name>]FROM S3 "bucket/path"[CONFIG <configuration_json>]CREDENTIALS <credentials_json>[WITH FILE = incr_backup_id][sync_options][(OPTION resource_pool = resource_pool_name)]<configuration_json>:'{"endpoint_url":"http://storage_provider_endpoint"}'<credentials_json>:'{"aws_access_key_id": "replace_with_your_access_key_id","aws_secret_access_key": "replace_with_your_secret_access_key"}'sync_options:WITH {SYNC | ASYNC} DURABILITY| WITH {SYNC | ASYNC} REPLICATION| WITH {SYNC | ASYNC} DURABILITY {SYNC | ASYNC} REPLICATION
Restore From Google Cloud Storage
RESTORE [DATABASE] <database_name> [AS <new_db_name>]FROM GCS "bucket/path"[CONFIG <configuration_json>]CREDENTIALS <credentials_json>[WITH FILE = incr_backup_id][sync_options] [(OPTION resource_pool = resource_pool_name)]<configuration_json>:'{}'<credentials_json>:'{"access_id": "replace_with_your_google_access_key","secret_key": "replace_with_your_google_secret_key"}'sync_options:WITH {SYNC | ASYNC} DURABILITY| WITH {SYNC | ASYNC} REPLICATION| WITH {SYNC | ASYNC} DURABILITY {SYNC | ASYNC} REPLICATION
See the remarks for details on the aws_
and aws_
.
Restore from Azure blobs
RESTORE [DATABASE] <database_name> [AS <new_db_name>]FROM AZURE "container/blob-prefix"CREDENTIALS <credentials_json>[CONFIG <configuration_json>][WITH FILE = incr_backup_id][sync_options][(OPTION resource_pool = resource_pool_name)]<credentials json>:'{"account_name": "your_account_name_here","account_key": "your_account_key_here"}'sync_options:WITH {SYNC | ASYNC} DURABILITY| WITH {SYNC | ASYNC} REPLICATION| WITH {SYNC | ASYNC} DURABILITY {SYNC | ASYNC} REPLICATION
Restore from a Connection Link
RESTORE [DATABASE] <database_name> [AS <new_db_name>]FROM LINK [link_database_name.]connection_name "backup_path";
Arguments
-
<database_
is the SingleStore database to restore to.name> The restored database always has the same number of partitions as the original database that you backed up. -
link_
is the database that stores the connection linkdatabase_ name connection_
.name -
If you wish to restore the backup of one database into a differently-named database, you can do so by specifying the
path
for S3 orprefix-key
for Azure blobs.See the Examples section for examples. -
WITH {SYNC | ASYNC} REPLICATION
specifies, following the database restore, whether high availability, redundancy-2 replication will be done synchronously or asynchronously.Synchronous replication from the master partitions will complete on all replicas before the commit of the transaction is acknowledged to the client application. If {SYNC | ASYNC} REPLICATION
is not specified, the replication setting from the database specified in thebackup_
orpath bucket/path
, orcontainer/blob-prefix
is used. -
WITH {SYNC | ASYNC} DURABILITY
specifies, following the database restore, whether in-memory database updates you make using DDL and DML commands are also saved to the log on disk synchronously or asynchronously.Synchronous updates to the log on disk will complete before the commit of the transaction is acknowledged to the client application. If WITH {SYNC | ASYNC} DURABILITY
is not specified, the durability setting from the database specified in thebackup_
orpath bucket/path
, orcontainer/blob-prefix
is used. -
You cannot specify
WITH SYNC DURABILITY ASYNC REPLICATION
. -
[WITH FILE = incr_
restores an incremental backup with thebackup_ id] incr_
that was assigned to the backup when it was taken.backup_ id -
ON WORKSPACE <workspace name>
specifies the workspace to which to restore the database.When
RESTORE DATABASE
is run on a child aggregator (that is part of a workspace), theON WORKSPACE
syntax is not necessary.The database is restored to the workspace of the child aggregator automatically. When restoring on the MA directly (i. e. , using the DDL endpoint in SingleStore Helios) use ON WORKSPACE
to specify the workspace to restore to.
Remarks
-
The
RESTORE
command replays a binary backup file in the same manner in which SingleStore Helios recovers a database snapshot during startup. -
CONFIG
andCREDENTIALS
can be specified in either order (CONFIG
followed byCREDENTIALS
orCREDENTIALS
followed byCONFIG
).For configuration examples refer BACKUP DATABASE -
A
RESTORE
operation temporarily puts the database being restored into therecovering snapshot
state.A database in this state cannot be queried. When the RESTORE
command finishes, it puts the database into theonline
state.See Database for more information. -
This command causes implicit commits.
Refer to COMMIT for more information. -
You can restore to S3, Azure, or GCS using a connection link.
However, you require the SHOW LINK
permission, provided by your administrator, to use a connection link. -
Refer to the Permission Matrix for the required permission.
Warning
SingleStore does not support restoring database backups from a newer version of SingleStore into an older version.
Restore from S3
-
aws_
is optional.session_ token This is only needed if your AWS account uses the AWS Security Token Service. -
role_
is optional.arn This is only needed if your AWS security is set up to require a role. The role needs to be alive for the entire restore process and will result in an assume_
on every S3 API call.role -
endpoint_
is optional.url -
When restoring in Helios via S3 gateway endpoint, you should just specify the bucket name without the
endpoint_
.url This is because a VPC endpoint is always created for S3 by default, hence all requests to S3 go internally through the AWS network. -
You should not specify the
compatibility_
setting, as you would when restoring from Google Cloud Storage using the S3 interface.mode -
As an alternative to using a
RESTORE .
statement where you specify the. . FROM S3 CONFIG
andCREDENTIALS
clauses, you can use theRESTORE .
statement, where you reference a connection link.. . FROM LINK For more information, see Configuring and Using Connection Links. -
You can restore a database to an HTTPS S3 target with an unverified SSL certificate by using the option:
CONFIG '{"verify_
.ssl": false}'
Restore From an S3-Compatible Storage Provider
-
RESTORE .
with the. . FROM S3 endpoint_
set to the URL of the S3 compatible storage provider restores an S3 compatible backup from the storage provider.url -
aws_
is optional.access_ key_ id It is the access key id for accessing the storage provider. -
aws_
is optional.secret_ access_ key It is the secret access key for accessing the storage provider. -
You should not specify the
compatibility_
setting, as you would when restoring from Google Cloud Storage using the S3 interface.mode -
As an alternative to using a
RESTORE .
statement where you specify the. . FROM S3 CONFIG
andCREDENTIALS
clauses, you can use theRESTORE .
statement, where you reference a connection link.. . FROM LINK For more information, see Configuring and Using Connection Links.
Restore From Google Cloud Storage
-
The
CONFIG
clause may optionally specify anendpoint_
.url -
The
CREDENTIALS
clause is required -
We support only HMAC keys
-
The
CREDENTIALS
clause should be a JSON object with two fields:
access_
: usually a 24 or 60 character alphanumeric string, which is linked to the Google account, typically all uppercase and starts with GOOG
.
secret_
: usually a 40 character Base-64 encoded string that is linked to a specific access_
.
As an alternative to using a RESTORE .
statement where you specify the CONFIG
and CREDENTIALS
clauses, you can use the RESTORE .
statement, where you reference a connection link.
Restore from Azure
-
The time limit given to download a file from Azure is 30 minutes.
This should be sufficient for most files at most download speeds. If that is not sufficient to download a file, you may get an error saying truncated tar archive
, in which case you may want to check your connection and retry the operation. -
As an alternative to using a
RESTORE .
statement where you specify the. . FROM AZURE CONFIG
clause, you can use theRESTORE .
statement, where you reference a connection link.. . FROM LINK For more information, see Configuring and Using Connection Links.
Restore from a Connection Link
-
The
RESTORE.
command restores a database from the specified container using a connection link.. FROM LINK To use this command, you only need to know the connection link name, not the connection details and configuration. -
This command supports S3, Azure, and GCS connections only.
Examples
Restore from S3
The following example restores from an S3 bucket.
RESTORE DATABASE memsql_demo FROM S3 "backup_bucket/backups/6_1_2018"CONFIG '{"region":"us-east-1"}'CREDENTIALS '{"aws_access_key_id":"replace_with_your_access_key_id","aws_secret_access_key":"replace_with_your_secret_access_key"}';
The following example restores a database(memsql_
) from an S3 bucket to a database with a different name(new_
).
RESTORE DATABASE new_memsql_demo FROM S3 "backup_bucket/backups/6_1_2018/memsql_demo.backup"CONFIG '{"region":"us-east-1"}'CREDENTIALS '{"aws_access_key_id":"replace_with_your_access_key_id","aws_secret_access_key":"replace_with_your_secret_access_key"}';
The following example demonstrates the CONFIG
clause for restoring from SSE-C encrypted buckets.
--- For Server-Side Encryption with Customer-Provided Encryption Keys (SSE-C) ---CONFIG '{"region":"us-east-1", "endpoint_url":"<target_endpoint_url>","x-amz-server-side-encryption-customer-algorithm":"AES256","x-amz-server-side-encryption-customer-key":"<key>","x-amz-server-side-encryption-customer-key-MD5":"<key>"}'
The following example restores a database from an S3 bucket to a the test-workspace
workspace.
RESTORE DATABASE test FROM S3 'path_to/mybucket/db.backup'CONFIG '{"region":"us-west-2","endpoint-url":"https://s3.amazonaws.com"}'CREDENTIALS '{"aws_access_key_id" : "replace_with_your_access_key_id","aws_secret_access_key":"replace_with_your_secret_access_key"}'ON WORKSPACE test-workspace;
Restore From Google Cloud Storage using the S3 Interface
The following example uses the S3 interface to restore from a Google Cloud Storage bucket.
RESTORE DATABASE memsql_demo FROM S3 "backup_bucket/backups/12_15_2019"CONFIG '{"compatibility_mode":true,"endpoint_url":"https://storage.googleapis.com"}'CREDENTIALS '{"aws_access_key_id":"replace_with_your_google_access_key","aws_secret_access_key":"replace_with_your_google_secret_key"}';
Restore from Azure
The following example restores from an Azure Container.
RESTORE DATABASE memsql_demo FROM AZURE "backup_container/backups/6_1_2018" CREDENTIALS '{"account_name":"your_account_name_here","account_key": "your_account_key_here"}';
The following example restores a database(memsql_
) from an Azure container to a database with a different name(new_
).
RESTORE DATABASE new_memsql_demo FROM AZURE "backup_container/backups/6_1_2018/memsql_demo.backup" CREDENTIALS '{"account_name":"your_account_name_here","account_key": "your_account_key_here"}';
Restore Using a Resource Pool
The following example restores a database from /my-backup-dir
, using an existing resource pool, general
.
RESTORE DATABASE memsql_demo FROM "/my-backup-dir" (OPTION resource_pool = general);
Restore Using a Connection Link
The following example restores the database db1
, from the bucket at the specified path, using an S3 connection link S3_
stored in the database db2
.S3_
already exists in db2
.
RESTORE DATABASE db1 FROM LINK db2.S3_link "backup_path/backups/6_1_2020"
Note: db1
is the database to be restored while db2
is the database of the connection link S3_
.
Common Errors
A common error is giving incorrect paths to the backup files to restore command.RESTORE
command should match the path that you gave to the BACKUP
command, unless you are restoring to a database with a different name in S3 or Azure restore, in which case, /old_
should be appended to your restore path.
Related Topics
Last modified: August 20, 2024