# 🚀 Day 9 of 100 Days of DevOps - Archiving, Compression & Backup Automation

Ritesh SinghRitesh Singh
3 min read

🧠 Why This Matters in DevOps

As a DevOps engineer, you're responsible for managing backups, logs, configuration snapshots, and transferring data efficiently. On Day 9, I explored:

  • Archiving files and folders with tar

  • Compressing data with gzip, bzip2, and zip

  • Automating backups using shell scripts

  • Using rsync for smart incremental backups


🔧 Tools and Commands Covered

Tool / CommandPurpose
tarArchive multiple files/folders
gzipCompress single files (.gz)
bzip2Stronger compression (.bz2)
zip/unzipPortable archive/compression
rsyncSync files locally or remotely

📂 Section 1: Archiving with tar

🔹 Create a .tar file (archive only)

tar -cvf mybackup.tar /home/ritesh/devops-journal

This guide covers essential commands for creating, extracting, and managing backups and compressed archives in Linux, along with a mini-project for automating backups using rsync and cron.

Section 1: Archiving with tar

Common tar Flags

  • -c: Create a new archive

  • -v: Verbose mode (shows files being processed)

  • -f: Specify the output file

Extract a .tar File

tar -xvf mybackup.tar

Section 2: Compressing Archives

Gzip Compression (Create .tar.gz)

tar -czvf mybackup.tar.gz /home/ritesh/devops-journal

Extract .tar.gz

tar -xzvf mybackup.tar.gz

Bzip2 Compression (Create .tar.bz2)

tar -cjvf mybackup.tar.bz2 /home/ritesh/devops-journal

Extract .tar.bz2

tar -xjvf mybackup.tar.bz2

Section 3: Using zip and unzip

Create a .zip Archive

zip -r mybackup.zip /home/ritesh/devops-journal

Extract a .zip File

unzip mybackup.zip

List Contents Without Extracting

unzip -l mybackup.zip

Section 4: Syncing with rsync

Local Folder Sync

rsync -av /home/ritesh/devops-journal/ /home/ritesh/backups/

Dry-Run Before Real Copy

rsync -av --dry-run /home/ritesh/Documents/ /home/ritesh/Downloads/

Remote Backup via SSH (Optional)

rsync -av /folder/ user@host:/remote/backup/

Section 5: Mini Project - Automated Backup Script

Backup Script: backup-devops.sh

#!/bin/bash

backup_dir="/home/ritesh/backups/devops-$(date +%F)"
mkdir -p "$backup_dir"

rsync -av /

Make the Script Executable

chmod +x backup-devops.sh

Schedule Backup Using Cron

  1. Edit your crontab:

     crontab -e
    
  2. Add the following line to run the backup every day at 8 PM:

     0 20 * * * /home/ritesh/cron-job-projects/backup-devops.sh
    

Cheatsheet Summary

CommandUse Case
tar -czvf backup.tar.gz folder/Archive + gzip compress
tar -xvzf backup.tar.gzExtract .tar.gz
zip -r file.zip folder/Create .zip archive
unzip file.zipExtract .zip archive
rsync -av src/ dest/Local backup/sync
rsync -av --dry-run src/ dest/Simulate the sync

Key Learnings

  • Understood the differences between .tar, .zip, and rsync

  • Practiced using tar, gzip, and rsync with real folders

  • Created an automated backup script using rsync and cron

  • Learned how to list, extract, and verify compressed archives

What's Next?

On Day 14, I’ll explore Log Management and Rotation, including:

  • Viewing and analyzing log files

  • Managing /var/log

  • Using tools like logrotate

🔗 GitHub – DevOps Journal

Final Thoughts

"Compression and backups are invisible until disaster strikes — now I can confidently automate both!"

#devops #linux #backup #bash #rsync #cron #compression #100DaysOfDevOps #learninginpublic

0
Subscribe to my newsletter

Read articles from Ritesh Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ritesh Singh
Ritesh Singh

Hi, I’m Ritesh 👋 I’m on a mission to become a DevOps Engineer — and I’m learning in public every single day.With a full-time commitment of 8–10 hours daily, I’m building skills in: ✅ Linux✅ Git & GitHub✅ Docker & Kubernetes✅ AWS EC2, S3✅ Jenkins, GitHub Actions✅ Terraform, Prometheus, Grafana I post daily blogs on Hashnode, push projects to GitHub, and stay active on LinkedIn and Twitter/X. Let’s connect, collaborate, and grow together 🚀 #100DaysOfDevOps #LearningInPublic #DevOps