A simple Bash script that archives the /var/log directory and stores the
compressed file in a chosen destination directory.
This script was written as a learning exercise while studying Linux and Bash scripting as a first-year Applied Computer Science student.
- Archives the
/var/logdirectory into a.tgzfile - Saves the archive in a specified directory (default:
/tmp) - Requires root privileges
- Measures and displays the execution time
- Logs
tarerrors to a file in/tmp
Make the script executable: chmod +x log-backup.sh
Run the script as root: sudo ./log-backup.sh [destination_directory]
If no destination directory is provided, /tmp is used by default.
Technologies Used
- Bash, Linux, tar
- The script must be run as root to access /var/log
- The destination directory must be writable
- This script is intended for educational purposes