Welcome to the Archive Tool 🛠️ — a simple and efficient Bash script for archiving directories with unique filenames. If you're working with log files or any other directories, this tool ensures your files are safely archived without overwriting existing archives. 🚀
- 📁 Archive Directories: Create
.tar.gz
archives of any directory. - 🔒 Admin Privileges Required: The script requests
sudo
to create the archive. - 🔄 Automatic File Naming: Prevents overwriting by generating unique archive names based on the current date and a unique number.
- 📅 Timestamped Archives: Archives are stamped with the current date for easy identification.
Make sure you have the following installed:
- 🐧 Bash (this is a shell script)
- 🔑 sudo access (administrative privileges)
Clone the repository and navigate to the folder:
git clone https://github.com/sean-njela/log_archive.git
cd log_archive
To use the tool, simply run the script with the directory you wish to archive as an argument:
./archive_tool.sh /path/to/directory
🛑 Note: You must pass exactly one argument — the directory path. The tool automatically handles the rest.
- The archived files are saved in the
archive
folder. - Naming convention:
log_archive_YYYY-MM-DD_<unique_number>.tar.gz
- Example:
archive/log_archive_2024-09-07_1000648.tar.gz
- Creates archive folder: If not already present.
- Checks for existing archives: Ensures no name collision by incrementing the unique number.
- Creates the archive: Compresses the directory using
tar
and places it inside thearchive
folder.
Here's how it works in action:
$ ./archive_tool.sh /var/log
Archiving ...
Archive created successfully: log_archive_2024-09-07_1000648.tar.gz in the directory: archive
-
🚫 Directory not found: If the specified directory doesn't exist, an error message will be displayed:
Error: Directory '/path/to/directory' not found.
-
🛑 Argument check: If the script is run without the required argument, you'll see:
Please insert 1 argument as a file or filepath.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to submit pull requests or raise issues. Contributions are always welcome!
Sean Njela
- GitHub: @seannjela
- Project Link: @Project_link
Feel free to contribute with UI effects and more logic!
Happy Archiving! 🎉