📁 File Management
📖 Official
Automated Folder Backup
Create automated backup scripts for important folders to prevent data loss
★★☆ Intermediate 15-20 min January 12, 2025
📋
Scenario
💬
Prompt
I need to create a backup plan: - Source directories: ~/Documents/Work and ~/Projects - Backup to: /Volumes/Backup/MyBackup - Frequency: Every day at 10 PM - Keep the last 7 days of backups - Compress backup files to save space Please create a backup script with these features: 1. Check if backup destination is available 2. Use rsync for incremental backup 3. Create timestamped folders for each backup 4. Compress old backups (older than 3 days) 5. Automatically delete backups older than 7 days 6. Log backup activities to ~/backup.log And save the script to ~/backup_script.sh
✨
Expected Result
💡
Tips
- • You can set up notifications when backup completes, so you know whether the backup succeeded even when away from your computer. You can use macOS's osascript or send email notifications.