ArchiverX is a powerful Linux shell scripting tool that automates log file archiving, compressing, and organizing logs to reduce manual effort and optimize storage. It provides advanced features for log management, including compression, rotation, and cleanup.
Here's what ArchiverX can do for you:
- Compress your log files into
.tar.gzarchives - Keep your log directories neat and organized
- Save space by compressing old logs
- Keep track of what was archived and when
First, let's get ArchiverX set up on your system:
# Get the code
git clone https://github.com/bavitha01/ArchiverX.git
# Move into the directory
cd ArchiverX
# Make it executable
chmod +x bin/log-archive.shThe basic command is simple:
./bin/log-archive.sh /path/to/your/logsWant to see what would be archived without actually doing it? Use the -n flag:
./bin/log-archive.sh -n /path/to/your/logsHere are some ways I use ArchiverX:
- Archiving system logs:
./bin/log-archive.sh /var/log- When I need maximum compression:
./bin/log-archive.sh -c 9 /var/log- Keeping archives longer:
./bin/log-archive.sh -a 60 /var/logThe script follows these steps:
-
First, it checks:
- Can it read your log directory?
- Is there enough disk space?
- Do you have the right permissions?
-
Then it archives:
- Creates a file like
logs_archive_20240315_123456.tar.gz - Compresses everything to save space
- Makes sure the archive isn't corrupted
- Creates a file like
-
Finally, it cleans up:
- Keeps a log of what was archived
- Removes old archives based on your settings
- Rotates log files to keep them from getting too big
Here are all the options you can use:
-d <dir> Where to put archives (default: ./archived_logs)
-l <size> Biggest log file size (default: 10MB)
-f <num> Number of log files to keep (default: 5)
-a <days> How long to keep archives (default: 30 days)
-c <level> How much to compress (1-9, default: 6)
-n Just show what would be archived
-h Show help
Your archives will be in:
archived_logsby default~/archiverx_archivesif you can't write to the default location- Check
archive_log.txtto see what was archived and when
If something's not working, try these:
- Can you read the log directory?
- Do you have enough disk space?
- Are your paths correct?
- Always use -n first to see what would be archived
- Start with the defaults, then adjust as needed
- Check the archive log to see what's happening
- Unix-like system (Linux, macOS)
- Basic commands:
tar,gzip,find,du,df
The script is designed to be non-destructive and only creates archives of your logs. It won't modify or delete your original files unless you explicitly add such functionality (e.g., log rotation). The tool uses absolute paths to ensure reliable execution from any location.