You are viewing an older version of this section. View current production version.
RESTORE
Restore data from a binary backup file.
Syntax
Local Restore
RESTORE [DATABASE] db_name FROM "backup_path" [WITH {SYNC | ASYNC} REPLICATION]
S3 Restore
RESTORE [DATABASE] db_name FROM S3 "bucket/path" [CONFIG configuration_json] CREDENTIALS credentials_json [WITH {SYNC | ASYNC} REPLICATION]
configuration_json:
'{"region":"your_region"}'
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"]
}'
Azure blobs Restore
RESTORE [DATABASE] db_name FROM AZURE "container/blob-prefix" CREDENTIALS credentials_json [WITH {SYNC | ASYNC} REPLICATION]
credentials json:
'{"account_name": "your_account_name_here",
"account_key": "your_account_key_here"
}'
Remarks
db_nameis the name of the MemSQL database to restore to.- If you wish to restore the backup of one database into a differently-named database, you can do so by specifying the full path to the old database’s .backup file in
backup_pathfor local backups orpathfor S3 orprefix-keyfor Azure blobs. For example, you can doBACKUP DATABASE db TO './path/'followed byRESTORE DATABASE newdb FROM './path/db.backup'. See the Examples section for examples. - The
RESTOREcommand replays a binary backup file in the same manner in which MemSQL recovers a database snapshot during startup. WITH {SYNC | ASYNC} REPLICATIONcontrols whether replication in high availability will be done synchronously or asynchronously. The default mode isASYNC. The default replication mode can be changed by changign the engine variablereplication_sync). Partitions replicated synchronously will ensure a transaction has reached all replicas before acknowledging the transaction as committed to the user client. While providing stronger consistency guarantees, this can negatively impact write performance. For more information, see Managing High Availability.- A
RESTOREoperation temporarily puts the database being restored into therecovering snapshotstate. A database in this state cannot be queried. When theRESTOREcommand finishes, it puts the database into theonlinestate. (see the Database topic for more information). - This command must be run on the master aggregator node (see Node Requirements for MemSQL Commands).
MemSQL does not support restoring database backups from a newer version of MemSQL into an older version.
Local Restore Remarks
backup_pathis the path used in BACKUP .- The path
backup_pathneeds to be accessible by thememsqldprocess. Paths are resolved relative to thememsqlbin/datadirectory.
S3 Restore Remarks
aws_session_tokenis optional. This is only needed if your AWS account uses the AWS Security Token Service.role_arnis optional. This is only needed if your AWS security is setup to require a role.
Azure Restore Remarks
- 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.
Example
Local Restore
The following example restores from the /var/lib/memsql/data/ directory.
RESTORE DATABASE memsql_demo FROM "./";
S3 Restore
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_demo) from an S3 bucket to a database with a different name(new_memsql_demo).
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"}';
Azure Restore
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_demo) from an Azure container to a database with a different name(new_memsql_demo).
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"}';
Common Errors
A common error is giving incorrect paths to the backup files to restore command. The path that you give to the 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_database_name.backup should be appended to your restore path.