A simple bash script to backup multiple directories into compressed ZIP archives with automatic cleanup of old backups.
- Backup multiple directories in a single run
- Automatic ZIP compression
- Date-based backup file naming
- Automatic cleanup of old backups based on retention policy
- Configuration file for easy customization
-
Copy the example configuration file:
cp backup_config.cfg.example backup_config.cfg
-
Edit
backup_config.cfgwith your specific settings:FOLDERS: Comma-separated list of directories to backupRETENTION_DAYS: Number of days to keep backup filesBACKUP_DIR: Directory where backups will be stored
-
Make sure the backup directory exists and has write permissions:
mkdir -p /path/to/backup/directory
Run the backup script:
./backup.shThe script will create ZIP files named {folder_name}_backup_{YYYY-MM-DD}.zip in your specified backup directory.
If you backup a folder named documents on 2024-01-15, the resulting file will be:
documents_backup_2024-01-15.zip
- bash
- zip command
- find command (for cleanup)
See LICENSE file for details.