Keep What Matters, Delete What Does Not

Data retention

Data retention is about deliberate housekeeping rather than endless hoarding. Keeping every log file and temporary export consumes disk space and increases breach exposure, while overly aggressive pruning removes records you may need years later.

A workable policy answers three questions for each folder or dataset:

  1. Legal or practical minimum: How long must it stay accessible?
  2. Useful lifespan: How long does it remain valuable?
  3. Deletion method: When and how should it be pruned automatically?

Retention by Data Type

Data TypeMinimum RetentionTypical TargetNotes
Personal photos and videosIndefiniteIndefiniteIrreplaceable family records
Financial and tax records6 years (HMRC guidance)7 yearsUK self-assessment and company records
Business correspondence3 years5 yearsContract reference
Medical recordsLifetimeLifetimePersonal health history
Code repositoriesActive lifetimeActive + 2 yearsArchive finished projects
System security logs90 days1 yearIncident review
Application debug logs14–30 days90 daysTroubleshooting
Backup snapshotsPer rotation policy7d / 4w / 12mSee Backup Strategies
Container imagesCurrent + previous2–3 versionsFast rollback
Browser bookmarksIndefiniteIndefiniteNegligible storage

Automated Lifecycle Policies

Restic Backup Rotation

# Keep: 7 daily, 4 weekly, 12 monthly, 5 yearly
restic forget \
  --keep-daily 7 \
  --keep-weekly 4 \
  --keep-monthly 12 \
  --keep-yearly 5 \
  --prune

Log Rotation with Logrotate

# /etc/logrotate.d/docker-logs
/var/lib/docker/containers/*/*.log {
    rotate 7
    daily
    compress
    delaycompress
    missingok
    notifempty
    copytruncate
}

Docker System Cleanup

# Remove stopped containers, unused networks, dangling images, build cache
docker system prune -f

# Also remove unused volumes (careful!)
docker system prune --volumes -f

# Automate via cron (weekly)
0 2 * * 0 /usr/bin/docker system prune -f >> /var/log/docker-prune.log 2>&1

Storage Tiering

Match drive speed and redundancy to how often files are read:

TierStorage MediumTypical ContentsRetention
HotNVMe SSD (RAID 1)Databases, active projects, container volumesAlways online
WarmHDD (RAID 5/6/SHR)Media libraries, local backups, recent archivesMonths to years
ColdExternal HDD off-siteCompleted projects, historical archivesYears to decades
Long-term archiveM-DISC optical, LTO tape, cold object storageCritical legal or family archivesDecades

UK GDPR Considerations for Self-Hosters

Purely personal household services sit outside UK GDPR, but hosting accounts for wider community members or business clients brings legal duties:

  • Right to erasure: Be able to locate and delete an individual's records on request.
  • Data minimisation: Collect only fields the service needs.
  • Storage limitation: Purge inactive accounts and stale logs on schedule.
  • Documentation: Record what personal data each service holds and where backups reside.

Directory Structure for Clean Retention

Organising folders by lifecycle makes automated cleanup straightforward:

/data/
  /active/          # Current work, hot tier
  /archive/
    /2024/          # Completed year
    /2025/          # Completed year
  /media/
    /photos/        # Organised by year/month
    /music/         # Permanent
    /video/         # Permanent
  /backup/
    /daily/         # 7-day rotation
    /weekly/        # 4-week rotation
    /monthly/       # 12-month rotation
  /temp/            # Auto-delete after 30 days

Auto-Delete Temporary Files

# Cron: delete files in /data/temp older than 30 days
0 3 * * * find /data/temp -type f -mtime +30 -delete

Deletion Methods

When retiring drives or scrubbing sensitive records, confirm the deletion level matches the risk:

  • Logical deletion: Removes filesystem pointers while blocks remain recoverable until overwritten.
  • Secure overwrite: Overwrites file blocks (shred), less reliable on wear-levelled SSDs.
  • Cryptographic erasure: Store sensitive volumes on LUKS-encrypted disks so destroying the encryption header renders all blocks unreadable immediately.

Building Your Retention Policy

  1. Inventory: List every directory and database you maintain.
  2. Classify: Assign each category a retention window and legal or practical reason.
  3. Automate: Configure restic forget, logrotate, and scratch-folder pruning.
  4. Document: Save a short retention.md file inside /docs/.
  5. Review annually: Adjust storage tiers and schedules as projects evolve.

Product links may include affiliate partnerships. See our affiliate disclosure for details.