Day 16 - How to Archive Jenkins Logs Using Tar, Zip, and Unzip

2 min read

๐งฐ Step-by-Step: Backup Jenkins Logs
๐ Step 1: Navigate to Jenkins Log Directory
cd /var/log/
ls jenkins/
๐๏ธ Step 2: Create a Compressed Archive Using tar
tar -czvf jenkins_06122020.tar.gz jenkins
Options Explained:
-c
: Create a new archive-z
: Compress using gzip-v
: Verbose output-f
: Specify output file name
โ Check archive:
file jenkins_06122020.tar.gz
ls -ltr
๐ฆ Step 3: Move Archive and Extract It
mv jenkins_06122020.tar.gz /tmp/
cd /tmp/
tar -xzvf jenkins_06122020.tar.gz
Extract to a different location:
tar -xzvf jenkins_06122020.tar.gz -C /opt/
๐ Bonus: Use zip & unzip as an Alternative
๐ฅ Install zip/unzip
yum install zip unzip -y
๐๏ธ Create Zip Archive
zip -r jenkins_06122020.zip jenkins
mv jenkins_06122020.zip /opt/
๐ Extract Zip
cd /opt/
rm -rf jenkins # Remove existing dir if needed
unzip jenkins_06122020.zip
๐ก What I Learned
โ
How to archive and compress logs with tar
โ
Use gzip compression with .tar.gz
โ
Extract archives to custom paths using -C
โ
Use zip/unzip for compatibility
โ
Ideal for scheduled backups and automation
๐ ๏ธ Real-World Use Case
Regular log archiving to save space
Moving logs to another server or S3 bucket
Debugging Jenkins issues from historical logs
๐ฎ Next Steps
On Day 17, I'll learn Debian Package Management & Network Utilities
0
Subscribe to my newsletter
Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
