Offline Copy of an Unlimited Storage Database
On this page
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"}';
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.
Warning
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";
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";
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";
Last modified: August 6, 2025