Offline Copy of an Unlimited Storage Database
On this page
Note
Unlimited storage databases are not available in all editions of SingleStore.
Suppose your unlimited storage database is named bottomless_
.bottomless_
include:
-
You are testing an application that uses
bottomless_
and you want to perform testing on the database copy.db -
You want to perform an audit of the contents of
bottomless_
at a time in the past.db You make a copy and restore the copy to a past milestone. -
bottomless_
has become corrupted and you make a copy and restore the copy to the point (the milestone) before the corruption occurred.db Then, you can compare bottomless_
with the copy.db
Procedure for Performing a Copy
The following example demonstrates how to copy an unlimited storage database, where Amazon S3 is used as the remote object store.
Setup
1.bottomless_
in the object storage bucket bottomless_
in the folder bottomless_
.
The following definition assumes you are using Amazon S3 as the object storage provider.
Note that aws_
is required only if your credentials in the CREDENTIALS
clause are temporary.
CREATE DATABASE bottomless_db ON S3 "bottomless_db_bucket/bottomless_db_folder"CONFIG '{"region":"us-east-1"}'CREDENTIALS '{"aws_access_key_id":"your_access_key_id","aws_secret_access_key":"your_secret_access_key","aws_session_token":"your_session_token"}';
The following definition assumes you are using Azure as the object storage provider.
CREATE DATABASE bottomless_db ON AZURE "bottomless_db_bucket/bottomless_db_folder"CONFIG ''CREDENTIALS '{"account_name":"your_account_name","account_key":"your_account_key"}';
The following definition assumes you are using GCS as the object storage provider.
CREATE DATABASE bottomless_db ON GCS "bottomless_db_bucket/bottomless_db_folder"CONFIG ''CREDENTIALS'{"access_id":"your_access_key_id", "secret_key":"your_secret_access_key"}';
2.bottomless_
.
USE bottomless_db;CREATE TABLE t(a INT);INSERT INTO t(a) VALUES (10);INSERT INTO t(a) VALUES (20);
3.
CREATE MILESTONE "after_second_insert" FOR bottomless_db;
4.bottomless_
:
INSERT INTO t(a) VALUES (30);INSERT INTO t(a) VALUES (40);
Perform the Copy
Detach bottomless_
and name the milestone after_
:
DETACH DATABASE bottomless_db AT "after_fourth_insert";
In remote object storage, create a new bucket copy_
where you will copy the objects from bottomless_
.
Next, copy the bottomless_
folder in the bottomless_
to the copy_
.
Your remote object storage provider may have a copy-on-write option that can be enabled when copying objects from one bucket to another.
Caution
The source database (bottomless_
) must remain detached while the objects from the source bucket (bottomless_
are copying.
After the copy completes, attach copy_
at the after_
, the milestone that was created right before you copied the objects in the remote object store.copy_
:
ATTACH DATABASE copy_of_bottomless_db ON S3 "copy_of_bottomless_db_bucket/bottomless_db"CONFIG '{"region":"us-east-1"}'CREDENTIALS '{"aws_access_key_id":"your_access_key_id","aws_secret_access_key":"your_secret_access_key"}'AT MILESTONE "after_fourth_insert";
ATTACH DATABASE copy_of_bottomless_db ON AZURE "copy_of_bottomless_db_bucket/bottomless_db"CONFIG ''CREDENTIALS '{"account_name":"your_account_name","account_key":"your_account_key"}'AT MILESTONE "after_fourth_insert";
For GCS:
ATTACH DATABASE copy_of_bottomless_db ON GCS "copy_of_bottomless_db_bucket/bottomless_db"CONFIG ''CREDENTIALS '{"access_id":"your_access_key_id", "secret_key":"your_secret_access_key"}'AT MILESTONE "after_fourth_insert";
Note
You could have also attached copy_
at a previous milestone, which would be after_
in this scenario.after_
milestone and after_
milestone.
Finally, attach bottomless_
at the after_
milestone, which is the same milestone you had detached it at.
ATTACH DATABASE bottomless_db ON S3 "bottomless_db_bucket/bottomless_db"CONFIG '{"region":"us-east-1"}'CREDENTIALS '{"aws_access_key_id":"your_access_key_id","aws_secret_access_key":"your_secret_access_key"}'AT MILESTONE "after_fourth_insert";
For Azure
ATTACH DATABASE bottomless_db ON AZURE "bottomless_db_bucket/bottomless_db"CONFIG ''CREDENTIALS '{"account_name":"your_account_name","account_key":"your_account_key"}'AT MILESTONE "after_fourth_insert";
For GCS
ATTACH DATABASE bottomless_db ON GCS "bottomless_db_bucket/bottomless_db"CONFIG ''CREDENTIALS '{"access_id":"your_access_key_id", "secret_key":"your_secret_access_key"}'AT MILESTONE "after_fourth_insert";
Last modified: May 5, 2023