Our databases contain valuable and business critical information and while there have always been manual ways to create restorable backups of Crate databases, as of version 0.53, we are pleased to announce the 'Snapshots' feature.
Snapshots allow you to create incremental backups of entire databases, specific tables or partitions and restore them through Crate's command line interface, Crash.
Setup
Repositories can be stored on shared file systems accessible to the whole cluster, hdfs or a read-only repository url accessible over several protocols.
Creating a shared file system repository requires a couple of steps.
Add the absolute paths where repositories could be located to config/crate.yml:
path.repo: /crate/repos, /repos
Connect to a Crate cluster using the Crash cli tool and create the repository for storing snapshots, changing my_snapshots
and location
to appropriate values for your cluster:
CREATE repository my_snapshots type fs WITH (location='crate_db', compress=true);
Find further options for the command here.
Creating a Backup
Create a snapshot, snapshot1
is the name for this snapshot:
CREATE snapshot my_snapshots.snapshot1 ALL WITH (wait_for_completion=true);
This creates a snapshot of all tables, waiting until the snapshot is created. There are other configuration options available, read full documentation of the command here.
Restoring a Backup
To restore a snapshot, drop any tables you want to restore:
DROP TABLE table_name;
Now restore the table from a snapshot:
RESTORE snapshot my_snapshots.snapshot1 TABLE table_name WITH (wait_for_completion=true);
For more details and best practice usage guides, head to our documentation.