Backup Retention Mathematics: Sizing Disk Capacity for 7-Day & 28-Day Retention Cycles
Keeping VPS backups is important, but storing every backup forever can create another problem: running out of disk space.
When backup files accumulate, they can consume storage needed by websites, databases, and system processes. This is why a backup retention policy matters.
A simple approach is to keep seven daily backups and four weekly full backups. The challenge is calculating how much storage they require and removing old files safely.
What Is a Backup Retention Policy?
A backup retention policy defines how long backup files should remain available before they are removed.
For example, a VPS administrator might choose:
-
Daily backups: Keep the latest 7 backups.
-
Weekly backups: Keep the latest 4 full backups.
-
Older archives: Remove them after checking the retention rules.
Daily backups help recover recent data, while weekly backups provide older recovery points.
The actual storage requirement depends on backup size, compression, data growth, and whether daily backups are full or incremental.
How to Calculate VPS Backup Storage
Backup capacity planning starts with a simple formula.
Total Backup Storage = Daily Backup Storage + Weekly Backup Storage
For a system keeping seven daily backups and four weekly full backups:
Total Storage = (7 × Daily Backup Size) + (4 × Weekly Full Backup Size)
This formula assumes each daily backup has a similar size and the weekly archives are full copies.
Example: Calculating Backup Storage
Consider a VPS with the following hypothetical backup sizes:
-
Full backup before compression: 20 GB
-
Full backup after compression: 12 GB
-
Daily incremental backup after compression: 1 GB
-
Daily backups retained: 7
-
Weekly full backups retained: 4
Daily backup storage:
7 × 1 GB = 7 GB
Weekly backup storage:
4 × 12 GB = 48 GB
Total estimated storage:
7 GB + 48 GB = 55 GB
This means the retained backup files would need approximately 55 GB of storage, assuming these sizes remain consistent.
This estimate excludes temporary files, filesystem overhead, and future data growth.
Understanding Backup Compression
Compression reduces the size of files stored in backup archives, but the amount saved depends on the type of data.
Text files, database exports, and some application files may compress well. Videos, images, and files that are already compressed often show smaller reductions.
You can estimate compressed storage with:
Compressed Size = Original Size × Compression Factor
For example, if a 20 GB backup is reduced to 12 GB:
20 GB × 0.60 = 12 GB
The compression factor is 0.60, meaning the archive occupies 60% of its original size.
Administrators should measure actual backup sizes instead of assuming every archive will achieve the same compression ratio.
Include Storage Space for Future Growth
A backup plan should not use every available gigabyte.
Applications continue producing new files, databases grow, and backup processes may create temporary archives before transferring or deleting them.
One planning method is to add a capacity allowance.
For example, using a 25% allowance:
55 GB × 1.25 = 68.75 GB
The estimated capacity becomes approximately 69 GB.
This 25% figure is only an example, not a universal requirement. Busy servers or applications with rapidly growing data may need considerably more.
Local backup space should also be planned separately from the storage required by the operating system and applications.
Daily Incremental vs Weekly Full Backups
A full backup contains all selected data at the time the backup runs.
An incremental backup contains changes since an earlier backup, according to the backup tool and method being used.
Incremental backups can save storage, but restoring them may require a full backup and a chain of incremental backups.
For example, deleting an older incremental backup without understanding these dependencies might make a newer recovery point unusable.
Before removing archives, confirm that the remaining backup chain can still be restored.
How Much Remote Backup Storage Is Needed?
Remote backups protect against problems affecting the VPS itself, such as local disk failure.
If the remote destination stores the same seven daily and four weekly archives from the earlier example, its starting estimate is also 55 GB.
The actual requirement may differ because remote storage systems can use versioning, deduplication, or their own retention rules.
Also consider incomplete uploads and temporary storage requirements.
Local and remote storage should be calculated separately because they may use different retention periods.
Automatically Removing Old VPS Backups
Manually deleting archives every week is inconvenient. Linux administrators can use find together with cron to automate cleanup.
For example, suppose weekly backup archives are stored in:
/var/backups/weekly/
Before deleting anything, preview archives older than 28 days using GNU find:
find /var/backups/weekly -maxdepth 1 -type f -name 'weekly-*.tar.gz' -mmin +40320 -print
This lists matching archives whose last modification time is more than 40,320 minutes (28 days) old.
After checking the results, the corresponding cleanup command is:
find /var/backups/weekly -maxdepth 1 -type f -name 'weekly-*.tar.gz' -mmin +40320 -delete
Important: These are example commands, not tested commands for a specific VPS. They should only be used after verifying the directory, filename pattern, and backup timestamps.
The cleanup command deletes matching files permanently. It does not guarantee that four valid weekly backups will remain. If backups were missed, or their timestamps changed, the number of retained archives may differ.
For an exact four-weekly-backup policy, count completed, verified backups and protect required recovery chains before deletion.
Schedule Backup Cleanup with Cron
Once the cleanup process has been tested, cron can run it automatically.
Open the crontab editor:
crontab -e
A script-based cleanup can be scheduled using:
0 4 * * * /usr/local/sbin/backup-cleanup.sh
This example runs the cleanup script daily at 4:00 AM, using the server's configured scheduling timezone.
The script should include appropriate safety checks and log its actions.
Run cleanup only after backup completion has been verified. Avoid removing files while backup jobs are still writing them.
Preventing VPS Disk Space Problems
A good retention policy works best when combined with regular disk monitoring.
Two useful Linux commands are:
df -h
This displays filesystem capacity and available space.
du -sh /var/backups
This estimates how much disk space the backup directory uses.
Administrators can also configure disk usage alerts before the filesystem becomes full.
For additional information about tracking VPS storage and other server resources, read this VPS resource monitoring guide.
Common Backup Retention Mistakes
Keeping Backups Without Checking Storage
Even compressed backups can eventually fill a disk. Review backup growth and storage availability regularly.
Removing Backups Too Early
Deleting archives without checking retention requirements can remove recovery points that are still needed.
Ignoring Failed Backups
A scheduled backup isn't necessarily a successful backup. Check logs, confirm archive integrity, and perform restore tests.
Storing Every Backup on the Same VPS
Local backups alone cannot protect data if the entire VPS storage becomes inaccessible. Maintain an independent remote copy where practical.
Final Thoughts
Backup retention should be based on actual file sizes, expected data growth, and recovery needs.
Start by measuring backup sizes, calculate the space required for daily and weekly archives, and include enough additional capacity for temporary files and future growth.
Use automated cleanup carefully, monitor disk usage, and test recovery regularly. A backup policy is useful only when the retained files can actually restore the data you need.
- Art
- Causes
- Crafts
- Dance
- Drinks
- Film
- Fitness
- Food
- Jeux
- Gardening
- Health
- Domicile
- Literature
- Music
- Networking
- Autre
- Party
- Religion
- Shopping
- Sports
- Theater
- Wellness