Backup & Recovery¶
Protecting cache data.
Backup¶
Local Cache¶
Server Cache¶
# Stop server for consistent backup
systemctl stop rninja-cached
tar -czf cache-backup.tar.gz -C /var/lib rninja-cache
systemctl start rninja-cached
Automated Backup¶
#!/bin/bash
# /etc/cron.daily/rninja-backup
BACKUP_DIR=/backups/rninja
DATE=$(date +%Y%m%d)
tar -czf $BACKUP_DIR/cache-$DATE.tar.gz -C /var/lib rninja-cache
# Keep 7 days
find $BACKUP_DIR -name "cache-*.tar.gz" -mtime +7 -delete
Recovery¶
Restore Local Cache¶
Restore Server Cache¶
systemctl stop rninja-cached
rm -rf /var/lib/rninja-cache
tar -xzf cache-backup.tar.gz -C /var/lib
systemctl start rninja-cached
Disaster Recovery¶
If cache is lost:
- Start with empty cache
- First builds populate cache
- Subsequent builds get hits
Cache is a performance optimization, not critical data.