🚀 DevOps Mastery: Volume Management, Process Monitoring & Automated Backups
DevOps isn’t just about automating deployments or managing clusters—it’s also about keeping your systems lean, mean, and always backed up. Today, we’re diving into three essential DevOps tasks:
1️⃣ Volume Management & Disk Usage
2️⃣ Process Management & Monitoring
3️⃣ Automating Backups with Shell Scripting
So, let’s break it down, step by step, with some hands-on fun. 🤓
4️⃣ Volume Management & Disk Usage
Task:
1️⃣ Create a directory /mnt/devops_data
.
2️⃣ Mount a new volume.
3️⃣ Verify the mount with df -h
and mount | grep devops_data
.
Solution:
First, create a directory that will act as our mount point:
mkdir -p /mnt/devops_data
Now, let's assume you have a new volume available (e.g., /dev/xvdf
). You can format and mount it like this:
mkfs.ext4 /dev/xvdf # Format the volume
mount /dev/xvdf /mnt/devops_data # Mount it
To make the mount persistent, add it to /etc/fstab
:
echo "/dev/xvdf /mnt/devops_data ext4 defaults 0 0" >> /etc/fstab
Verification:
df -h | grep devops_data # Check disk space
mount | grep devops_data # Verify mount
For the above image instead of giving name devops_data i gave attach_single_ssd
Boom! Your volume is now live. 🎯
5️⃣ Process Management & Monitoring
Task:
1️⃣ Start a background process that pings Google.
2️⃣ Monitor it using ps
, top
, and htop
.
3️⃣ Kill the process and verify it's gone.
Solution:
Start a background process:
ping google.com > ping_test.log &
Find its Process ID (PID):
ps aux | grep ping
Monitor it using:
top # Interactive system monitoring
htop # Better version of top (if installed)
If You want to fillter the ping word:
Kill it once you’re done:
kill <PID>
After killing the process check again it will show Terminated.
Verify that it's gone:
ps aux | grep ping
Congrats! You just tamed your first rogue process. 🦾
6️⃣ Automate Backups with Shell Scripting
Task:
1️⃣ Write a shell script to back up /devops_workspace
.
2️⃣ Save it in /backups
.
3️⃣ Schedule it using cron
.
4️⃣ Display a success message in green text.
Solution:
Backup Script (backup.sh
)
#!/bin/bash
<<help
this script does backup from server to s3 backup automatically
help
#take arguments from cmd as $1 -->for backup file dest, and $2 for src from where you wiill get file for backup
dest=$1
src=$2
timestamp=$(date '+%d-%m-%y-%H-%M-%S')
zip -r "$dest/backup-$timestamp.zip" "$2"
Make the script executable:
chmod +x backup.sh
Schedule it in cron
:
crontab -e
Add the following line to run the backup every day at midnight:
* * * * * /path/to/backup.sh
This will backup like this.
That’s it! Your backups will run automatically. 🛡️
Final Thoughts
Mastering volume management, process monitoring, and backups is crucial for any DevOps engineer. These tasks ensure efficient resource management, system stability, and disaster recovery. Keep practicing, and you'll soon automate everything like a pro! 💻🔥
Got any questions or cool tricks? Drop them in the comments! 🚀