Configure retention policies
Overview
Over time, the ClusterCockpit database and job archive can grow significantly, especially in production environments with high job counts. Retention policies help keep your storage at a manageable size by automatically removing or archiving old jobs.
Why use retention policies?
Without retention policies:
- The SQLite database file can grow to tens of gigabytes
- The job archive can reach terabytes in size
- Storage requirements increase indefinitely
- System performance may degrade
A typical multi-cluster setup over 5 years can accumulate:
- 75 GB for the SQLite database
- 1.4 TB for the job archive
Retention policies allow you to balance data retention needs with storage capacity.
Retention policy options
ClusterCockpit supports three retention policies:
None (default)
No automatic cleanup. Jobs are kept indefinitely.
{
"archive": {
"kind": "file",
"path": "./var/job-archive"
}
}
Delete
Permanently removes jobs older than the specified age from both the job archive and the database.
Use when:
- Storage space is limited
- You don’t need long-term job data
- You have external backups or data exports
Configuration example:
{
"archive": {
"kind": "file",
"path": "./var/job-archive",
"retention": {
"policy": "delete",
"age": 365,
"includeDB": true
}
}
}
This configuration will:
- Delete jobs older than 365 days
- Remove them from both the job archive and database
- Run automatically based on the cleanup interval
Move
Moves old jobs to a separate location for long-term archival while removing them from the active database.
Use when:
- You need to preserve historical data
- You want to reduce active database size
- You can store archived data on cheaper, slower storage
Configuration example:
{
"archive": {
"kind": "file",
"path": "./var/job-archive",
"retention": {
"policy": "move",
"age": 365,
"location": "/mnt/archive/old-jobs",
"includeDB": true
}
}
}
This configuration will:
- Move jobs older than 365 days to
/mnt/archive/old-jobs - Remove them from the active database
- Preserve the data for potential future analysis
Configuration parameters
archive.retention section
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
policy | string | Yes | - | Retention policy: none, delete, or move |
age | integer | No | 7 | Age threshold in days. Jobs older than this are affected |
includeDB | boolean | No | true | Also remove jobs from the database (not just archive) |
location | string | For move | - | Target directory for moved jobs (only for move policy) |
Complete configuration examples
Example 1: One-year retention with deletion
Suitable for environments with limited storage:
{
"archive": {
"kind": "file",
"path": "./var/job-archive",
"retention": {
"policy": "delete",
"age": 365,
"includeDB": true
}
}
}
Example 2: Two-tier archival system
Keep 6 months active, move older data to long-term storage:
{
"archive": {
"kind": "file",
"path": "./var/job-archive",
"retention": {
"policy": "move",
"age": 180,
"location": "/mnt/slow-storage/archive",
"includeDB": true
}
}
}
Example 3: S3 backend with retention
Using S3 object storage with one-year retention:
{
"archive": {
"kind": "s3",
"endpoint": "https://s3.example.com",
"bucket": "clustercockpit-jobs",
"access-key": "your-access-key",
"secret-key": "your-secret-key",
"retention": {
"policy": "delete",
"age": 365,
"includeDB": true
}
}
}
How retention policies work
- Automatic execution: Retention policies run automatically based on the configured interval
- Age calculation: Jobs are evaluated based on their
startTimefield - Batch processing: All jobs older than the specified age are processed in one operation
- Database cleanup: When
includeDB: true, corresponding database entries are removed - Archive handling: Based on policy (
deleteremoves,moverelocates)
Best practices
Planning retention periods
Consider these factors when setting the age parameter:
- Accounting requirements: Some organizations require job data for billing/auditing
- Research needs: Longer retention for research clusters where users may need historical data
- Storage capacity: Available disk space and growth rate
- Compliance: Legal or institutional data retention policies
Recommended retention periods:
| Use Case | Suggested Age |
|---|---|
| Development/testing | 30-90 days |
| Production (limited storage) | 180-365 days |
| Production (ample storage) | 365-730 days |
| Research/archival | 730+ days or use move policy |
Storage considerations
For move policy
- Mount the target
locationon slower, cheaper storage (e.g., spinning disks, network storage) - Ensure sufficient space at the target location
- Consider periodic backups of the moved archive
- Document the archive structure for future retrieval
For delete policy
- Create backups first: Always backup your database and job archive before enabling deletion
- Test on a copy: Verify the retention policy works as expected on test data
- Export important data: Consider exporting summary statistics or critical job data before deletion
Monitoring and maintenance
Track archive size: Monitor growth to adjust retention periods
du -sh /var/job-archive du -sh /path/to/database.dbVerify retention execution: Check logs for retention policy runs
grep -i retention /var/log/cc-backend.logRegular backups: Backup before changing retention settings
cp -r /var/job-archive /backup/job-archive-$(date +%Y%m%d) cp /var/clustercockpit.db /backup/clustercockpit-$(date +%Y%m%d).db
Restoring deleted jobs
If using move policy
Jobs moved to the retention location can be restored:
Stop
cc-backendUse the
archive-managertool to import jobs back:cd tools/archive-manager go build ./archive-manager -import \ -src-config '{"kind":"file","path":"/mnt/archive/old-jobs"}' \ -dst-config '{"kind":"file","path":"./var/job-archive"}'Rebuild database from archive:
./cc-backend -init-dbRestart
cc-backend
If using delete policy
Jobs cannot be restored unless you have external backups. This is why backups are critical before enabling deletion.
Related tools
- archive-manager: Manage and validate job archives
- archive-migration: Migrate archives between schema versions
- Database migration: See database migration guide
Troubleshooting
Retention policy not running
Check:
- Verify
archive.retentionis properly configured inconfig.json - Ensure
cc-backendwas restarted after configuration changes - Check logs for errors:
grep -i retention /var/log/cc-backend.log
Database size not decreasing
Possible causes:
includeDB: false- Database entries are not being removedSQLite doesn’t automatically reclaim space - run
VACUUM:sqlite3 /var/clustercockpit.db "VACUUM;"
Jobs not being moved to target location
Check:
- Target directory exists and is writable
- Sufficient disk space at target location
- File permissions allow
cc-backendto write tolocation - Path in
locationis absolute, not relative
Performance impact
If retention policy execution causes performance issues:
- Consider running during off-peak hours (feature may require manual execution)
- Reduce the number of old jobs by running retention more frequently with shorter age periods
- Use more powerful hardware for the database operations
See also
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.