Introduction:
This bash script creates backups of specified directories. It compresses the backup into a tar archive and saves it with a timestamp, ensuring your important files are secure.
Instructions:
To use this script, run the following commands after editing the source and destination directories:
Example Output:
This bash script creates backups of specified directories. It compresses the backup into a tar archive and saves it with a timestamp, ensuring your important files are secure.
Bash:
#!/bin/bash
# Define backup source and destination
SOURCE_DIR="/path/to/important/files"
DEST_DIR="/path/to/backup/location"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
# Create backup archive
tar -czf "$DEST_DIR/backup_$TIMESTAMP.tar.gz" "$SOURCE_DIR"
echo "Backup created at $DEST_DIR/backup_$TIMESTAMP.tar.gz"
Instructions:
To use this script, run the following commands after editing the source and destination directories:
Code:
chmod +x backup_script.sh
./backup_script.sh
Example Output:
Code:
Backup created at /path/to/backup/location/backup_20231010_142530.tar.gz