nodetool enablebackup
Enables incremental backup.
Synopsis
Section titled “Synopsis”nodetool [connection_options] enablebackupSee connection options for connection options.
Description
Section titled “Description”nodetool enablebackup enables incremental backup mode. When enabled, Cassandra creates hard links to newly flushed SSTables in a backups subdirectory. This allows continuous backup of data as it's written.
Non-Persistent Setting
This setting is applied at runtime only and does not persist across node restarts. After a restart, incremental backup reverts to the incremental_backups setting in cassandra.yaml (default: false).
To make the change permanent, update cassandra.yaml:
incremental_backups: trueHow Incremental Backup Works
Section titled “How Incremental Backup Works”When incremental backup is enabled:
- Each time new SSTables are created (during flush, compaction, or other operations), a hard link is created
- Hard links go to:
<data_dir>/<keyspace>/<table>/backups/ - Links point to the same data blocks (no extra disk space initially)
- Backup files remain even after compaction removes the original
Example
Section titled “Example”nodetool enablebackupVerify:
nodetool statusbackup# Expected: runningBackup Location
Section titled “Backup Location”/var/lib/cassandra/data/<keyspace>/<table>-<uuid>/backups/Example:
/var/lib/cassandra/data/my_keyspace/my_table-abc123/backups/├── nb-1-big-Data.db├── nb-1-big-Index.db├── nb-1-big-Filter.db└── ...Use Cases
Section titled “Use Cases”Continuous Backup Strategy
Section titled “Continuous Backup Strategy”# 1. Enable incremental backupnodetool enablebackup
# 2. Periodically copy backup files to external storagersync -av /var/lib/cassandra/data/*/*/backups/ /backup/incremental/
# 3. Clear processed backupsrm -rf /var/lib/cassandra/data/*/*/backups/*Combined with Snapshots
Section titled “Combined with Snapshots”# Weekly full backup (snapshot)nodetool snapshot -t weekly_$(date +%Y%m%d)
# Daily incremental backupnodetool enablebackup# ... copy backups daily ...Incremental vs Snapshot Backup
Section titled “Incremental vs Snapshot Backup”| Aspect | Incremental | Snapshot |
|---|---|---|
| Trigger | Automatic on flush | Manual command |
| Content | New SSTables only | All current SSTables |
| Disk usage | Grows over time | Point-in-time |
| Recovery | Need base + incrementals | Self-contained |
| Overhead | Continuous | On-demand |
Workflow: Incremental Backup
Section titled “Workflow: Incremental Backup”# 1. Take initial snapshot (baseline)nodetool snapshot -t baseline
# 2. Enable incremental backupnodetool enablebackup
# 3. Application writes data...
# 4. Periodically copy incrementalsrsync -av /var/lib/cassandra/data/*/*/backups/ /backup/server/
# 5. Clear processed incrementalsfind /var/lib/cassandra/data -path "*/backups/*" -delete
# 6. Repeat steps 4-5Restoration Process
Section titled “Restoration Process”To restore from incremental backups:
# 1. Restore baseline snapshotcp -r /backup/snapshots/baseline/* /var/lib/cassandra/data/
# 2. Layer incremental backupscp -r /backup/incremental/* /var/lib/cassandra/data/
# 3. Start Cassandra or refreshnodetool refresh keyspace tableDisk Space Considerations
Section titled “Disk Space Considerations”Space Growth
Incremental backups consume disk space:
- Hard links share data initially
- After compaction, backup files use real space
- Old backup files not automatically deleted
Monitoring Space
Section titled “Monitoring Space”# Check backup directory sizedu -sh /var/lib/cassandra/data/*/*/backups/
# Total backup sizefind /var/lib/cassandra/data -path "*/backups/*" -type f -exec du -ch {} + | tail -1Cleanup
Section titled “Cleanup”# Remove processed backupsfind /var/lib/cassandra/data -path "*/backups/*" -deleteConfiguration
Section titled “Configuration”cassandra.yaml Setting
Section titled “cassandra.yaml Setting”incremental_backups: true # Or use nodetool enablebackupRuntime vs Configuration
Section titled “Runtime vs Configuration”| Method | Persistence |
|---|---|
nodetool enablebackup | Until restart |
cassandra.yaml | Permanent |
Automation Script
Section titled “Automation Script”#!/bin/bash# incremental_backup.sh - Copy and clear incrementals
BACKUP_DIR="/backup/cassandra/incremental/$(date +%Y%m%d_%H%M)"DATA_DIR="/var/lib/cassandra/data"
# Create backup directorymkdir -p "$BACKUP_DIR"
# Copy incremental backupsfor backup_path in $(find $DATA_DIR -type d -name "backups"); do if [ "$(ls -A $backup_path 2>/dev/null)" ]; then # Get relative path for organization rel_path=$(echo $backup_path | sed "s|$DATA_DIR/||") mkdir -p "$BACKUP_DIR/$rel_path" mv "$backup_path"/* "$BACKUP_DIR/$rel_path/" fidone
echo "Incremental backup completed: $BACKUP_DIR"Best Practices
Section titled “Best Practices”Incremental Backup Guidelines
- Start with a snapshot - Need baseline for recovery
- Regular cleanup - Move and delete processed backups
- Monitor disk space - Backups grow continuously
- Test restoration - Verify backup/restore process
- Document retention - Know what's backed up and when
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| disablebackup | Disable incremental backup |
| statusbackup | Check backup status |
| snapshot | Create full backup |
| listsnapshots | List snapshots |