Blog 3

📝 Blog Post #3

Title: Learning to Automate My WordPress Server at SLC

When I first started working with WordPress at St. Lawrence College, I had no idea how much was going on behind the scenes. Sure, I could post blogs and customize themes, but this latest project taught me what really goes into managing a website — especially when it comes to monitoring and backups.

Over the last couple of weeks, I learned how to automate my WordPress server using Linux shell scripts, cron jobs, Discord webhooks, and cloud storage. At first, it sounded overwhelming, but once I broke it down and worked through each part, it turned into one of the most satisfying learning experiences I’ve had so far.


🖥️ Setting Up Monitoring Alerts

One of the first tasks was to set up a monitoring script. The goal was to make sure my server could check its own CPU usage, available memory, and disk space. If any of those went over a certain limit (like 90% usage), the script would send an alert to my Discord server.

To make that happen, I created a Discord webhook and added it to my monitor.sh script. I used the top, free, and df commands to get the system stats. Then I set up a cron job to run the script every 10 minutes automatically.

The first time I saw my Discord bot post an alert saying “🔥 CPU usage is at 100%” — I was shocked… and also kind of proud! That meant my script was actually working in real-time, just like it should.


💾 Automating Backups with rclone

The second major task was setting up automated backups. I needed to create a script that could:

  • Dump my WordPress MySQL database
  • Compress my entire WordPress directory (/var/www/html)
  • Upload the final backup to Google Drive using rclone

At first, I struggled with getting the Google Drive connection to work from my VPS, especially because it doesn’t have a browser. I had to use rclone’s manual authorization mode by generating the token from my local PC and pasting it into the server.

Once that was done, I created a wp-backup.sh script that runs every day at 3 AM. It creates a .tar.gz file that contains both the database and website files, and it uploads them to Google Drive automatically. I even added a line to delete old backups that are more than 7 days old to save space.

It felt great to know that my website was backed up daily, without me having to remember to do anything.


🧪 Testing and Troubleshooting

There were definitely some challenges along the way. For example, my MySQL user didn’t have the right permissions, so I had to add the --no-tablespaces flag to make the database dump work. I also ran into an issue where the webhook wasn’t sending alerts — I fixed it by lowering the thresholds temporarily to force a test alert.

I learned how to test one thing at a time and not get discouraged when something didn’t work right away. Eventually, everything came together.


📚 What I Learned

This project taught me a lot more than just technical commands. I learned how to automate tasks, how to think like a sysadmin, and how important it is to have a backup and monitoring system in place — even for a student project.

Most importantly, it taught me how to troubleshoot and problem-solve. If something didn’t work, I looked up commands, tested things out, and asked for help when I needed it.

Now, I can proudly say that my WordPress site:

  • Sends alerts to Discord when something is wrong ✅
  • Backs itself up every day to Google Drive ✅
  • Can be restored easily if anything breaks ✅

This assignment was a big step forward for me in understanding how real servers are managed, and I’m glad I got to experience it.