-
Notifications
You must be signed in to change notification settings - Fork 51
Meta DB Backup Guide
ByoungSeob Kim edited this page Mar 4, 2026
·
1 revision
- CB-Spider stores all management metadata (CSP connection configs, resource IIDs, etc.) in a single SQLite3 database file (
meta_db/cb-spider.db). - If this file is corrupted or accidentally deleted, it becomes very difficult to identify and manage resources that Spider was tracking across multiple CSPs and Regions.
- To mitigate this risk, CB-Spider provides an automatic background backup feature that periodically creates consistent copies of the Meta DB using SQLite3's
VACUUM INTO.
┌───────────────────────────────────────────────────────────────┐
│ CB-Spider Meta DB Backup │
│ │
│ meta_db/ │
│ ├── cb-spider.db ← Active Meta DB │
│ └── backups/ ← Backup Directory │
│ ├── cb-spider_backup_20260305_060000.db │
│ ├── cb-spider_backup_20260305_120000.db │
│ ├── cb-spider_backup_20260305_180000.db │
│ └── ... (up to MaxCount files, oldest rotated out) │
└───────────────────────────────────────────────────────────────┘
- Backups are performed using SQLite3's
VACUUM INTOcommand. - This is a fully online operation: reads and writes to the Meta DB continue normally during backup.
- The backup file is an optimized, consistent snapshot of the database at the time of execution.
| Item | Default | Description |
|---|---|---|
| Startup Backup | Always | An immediate backup is performed when Spider server starts |
| Periodic Backup | Every 6 hours | Background scheduler runs at the configured interval |
| Minimum Interval | 1 minute | Values below 1 minute are automatically adjusted to 1 minute |
- Only the maximum backup count (
MaxCount) is enforced. - When the number of backup files exceeds
MaxCount, the oldest files are deleted first. - There is no time-based expiration; retention is purely count-based.
| Item | Default | Description |
|---|---|---|
| Max Backup Count | 10 | Number of backup files to keep |
cb-spider_backup_YYYYMMDD_HHMMSS.db
- Example:
cb-spider_backup_20260305_180000.db - Files are sorted by name (timestamp order) for rotation.
All backup settings are configured via environment variables in setup.env.
All settings are optional. If not set, defaults are used without errors.
| Environment Variable | Default | Description |
|---|---|---|
SPIDER_BACKUP_ENABLED |
true |
Enable/disable backup (true, false, on, off, 1, 0) |
SPIDER_BACKUP_INTERVAL |
6h |
Backup interval in Go duration format (1h, 30m, 24h, etc.) |
SPIDER_BACKUP_DIR |
$CBSPIDER_ROOT/meta_db/backups |
Directory to store backup files |
SPIDER_BACKUP_MAX_COUNT |
10 |
Maximum number of backup files to retain |
Default (no configuration needed)
# All defaults apply: enabled, 6h interval, 10 backups
# No environment variables need to be setHigh-frequency backup
export SPIDER_BACKUP_INTERVAL=1h
export SPIDER_BACKUP_MAX_COUNT=24Daily backup
export SPIDER_BACKUP_INTERVAL=24h
export SPIDER_BACKUP_MAX_COUNT=7Disable backup
export SPIDER_BACKUP_ENABLED=falseWhen the Meta DB (cb-spider.db) is corrupted or deleted, restore it from the latest backup:
Step 1. Stop the CB-Spider server.
Step 2. (Optional) Move or rename the corrupted DB file:
$ mv meta_db/cb-spider.db meta_db/cb-spider.db.corrupted
Step 3. Copy the latest backup file as the active DB:
$ cp meta_db/backups/cb-spider_backup_20260305_180000.db meta_db/cb-spider.db
Step 4. Restart the CB-Spider server.
Important: The server must be stopped before replacing the DB file, because SQLite uses file-level locking.
# List backups sorted by time (newest last)
$ ls -lt meta_db/backups/The file with the most recent timestamp in its name is the latest backup.
All backup operations are logged via cb-log with the [MSB] (Meta Store Backup) prefix:
| Log Level | Message | Description |
|---|---|---|
| INFO | [MSB] Meta DB Backup Scheduler started. |
Scheduler initialization |
| INFO | [MSB] Starting meta DB backup... |
Backup cycle begins |
| INFO | [MSB] Meta DB backup completed: <path> (took <duration>) |
Backup success |
| INFO | [MSB] Deleted old backup: <filename> |
Rotation cleanup |
| WARN | [MSB] Meta DB file not found: <path>. Skipping backup. |
Source DB missing |
| ERROR | [MSB] Meta DB backup failed: <error> |
Backup failure |
| ERROR | [MSB] Backup rotation failed: <error> |
Rotation failure |
apiserver.go (main)
│
├── LoadBackupConfig() ← Read env vars (backup_config.go)
│
└── StartBackupScheduler() ← Launch background goroutine (backup_scheduler.go)
│
├── Immediate backup on startup
│
└── Periodic loop (time.Ticker)
│
├── BackupMetaDB() ← VACUUM INTO (backup.go)
│
└── RotateBackups() ← Delete oldest if > MaxCount (backup.go)
| Source File | Description |
|---|---|
info-store/backup_config.go |
Configuration parsing with safe defaults |
info-store/backup.go |
Core backup logic (VACUUM INTO) and rotation |
info-store/backup_scheduler.go |
Background scheduler with graceful shutdown |
-
Install & Start Guide
-
Usage Guide
- Usage Overview
- Connection Management
- Region/Zone Info
- Quota Info
- VM Price Info
- VM Image Info
- VM Spec Info
- VPC/Subnet Management
- Security Group Management
- KeyPair Management
- VM Management
- Disk Management
- Network Load Balancer(NLB) Management
- Kubernetes Cluster Management
- Object Storage(S3) Management
- Tag Management
- Cloud Driver Capability Info
- Function Menu
- MetaDB Auto Backup
- How to get CSP Credentials
- Tutorials
- Developer Guide
- Cloud Driver Developer Guide
- CB‐Spider Multi‐Cloud Driver Developer Team Skill
- Cloud Driver Developer Guide-WIP
- VM SSH Key Development Guide-WIP
- VM User Development Guide
- What is the CSP SDK API Version of drivers
- Region Zone Info and Driver API
- (StartVM TerminateVM) API Call Counts and Waiting
- StartVM and TerminateVM Main Flow of drivers
- VM Root Disk Configuration Guide
- Security Group Rules and Driver API
- Network Load Balancer and Driver API
- VM Snapshot, MyImage and Disk Overview
- Kubernetes and Driver API(PMKS, K8S)
- Tag and Cloud Driver API
- AnyCall API Extension Guide
- How to ...
- How to Use AWS S3 with Credentials
- How to Use Alibaba ECS i1.* Instance Types
- How to provision GPU VMs
- How to test CB Spider with Mock Driver
- How to install CB Spider on WSL2 under 공유기/사설망
- How to install CB Spider on macOS
- How to run CB Spider Container on macOS
- How to get Azure available Regions
- How to profile memory usage in Golang
- [For Cloud-Migrator]