A bash script that backs up a directory, compresses it with a timestamp, logs success/failure, and automatically deletes backups older than 7 days.
- Directory backup with timestamped
.tar.gznaming - Success/failure logging with timestamps
- Automatic rotation — deletes backups older than 7 days
- Takes source and destination as arguments
chmod +x backup.sh
./backup.sh <source_directory> <destination_directory>tar— compressiondate— timestampingfind— locating and deleting old backups (rotation)
See sample_backup.log for example log entries.