⏰Cron Schedules
Backup Strategy (Combined Schedule)
Multi-tier backup schedule: hourly, daily, weekly, monthly.
Explanation
Comprehensive backup strategy with different retention policies for each tier.
Examples
Hourly Backups
Output
0 * * * * - Keep 24 hours
Daily Backups
Output
0 2 * * * - Keep 7 days
Weekly Backups
Output
0 3 * * 0 - Keep 4 weeks
Monthly Backups
Output
0 4 1 * * - Keep 12 months
Code Examples
Crontab
# Crontab entries for multi-tier backups
# Hourly - Keep last 24
0 * * * * /scripts/backup-hourly.sh
# Daily at 2 AM - Keep last 7 days
0 2 * * * /scripts/backup-daily.sh
# Weekly on Sunday at 3 AM - Keep last 4 weeks
0 3 * * 0 /scripts/backup-weekly.sh
# Monthly on 1st at 4 AM - Keep last 12 months
0 4 1 * * /scripts/backup-monthly.sh Backup Script
#!/bin/bash
# backup-daily.sh
BACKUP_DIR="/backups/daily"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
RETENTION_DAYS=7
# Create backup
tar -czf "$BACKUP_DIR/backup_$TIMESTAMP.tar.gz" /data
# Delete backups older than retention period
find "$BACKUP_DIR" -name "backup_*.tar.gz" -mtime +$RETENTION_DAYS -delete
# Log completion
echo "$(date): Daily backup completed" >> /var/log/backups.logTry it Now
💡 Tips
- Stagger backup times to avoid conflicts
- Implement rotation/cleanup for disk space
- Store critical monthly backups off-site
- Monitor backup success/failure
- Test restore process regularly
- Compress backups to save space
- Consider incremental vs full backups
- Document retention policies
⚠️ Common Pitfalls
- Overlapping backups can cause corruption
- Disk space fills up without rotation
- Never tested restore means backups are useless
- Long backups may overlap with next schedule
- Consider backup window and system load