When a CI/CD Test Deletes Your Media Folder: Lessons from a Real-World DevOps Mistake

By khoanc, at: Sept. 13, 2025, 4:12 p.m.

Estimated Reading Time: __READING_TIME__ minutes

When a CI/CD Test Deletes Your Media Folder: Lessons from a Real-World DevOps Mistake
When a CI/CD Test Deletes Your Media Folder: Lessons from a Real-World DevOps Mistake

 

“It worked on my machine”… until it wiped our production media folder.

 

Recently, we onboarded a new DevOps intern at Glinteco. One of his first assignments was to set up CI/CD using GitHub Actions to deploy our Django application to the development server.

 

It was a relatively safe task or so we thought.

 

The Mistake That Cost Us 30% of Our Media Files

 

In his attempt to run deployment tests, the intern configured the CI/CD pipeline to deploy the app to a test site on the development server.

 

However, the development server had shared directories with real production data, including mounted folders used by active client sites.

 

One misconfigured path in the CI/CD pipeline caused the deployment to overwrite a shared MEDIA folder, which hosted uploaded images and files for a live Django project.

 

No backup. No warning. Just gone.

 

Suddenly, live site pages were full of broken image links. Customers were affected. And we had to act fast.

 

How We Recovered from Disaster

 

Our DevOps team sprang into action:

 

  • Checked GitHub commits and CI logs to trace when the deletion occurred
     

  • Searched for file names and paths from old database references and application logs
     

  • Dug through all local development machines and deployment terminals used by our team to recover cached or previously uploaded images
     

  • Manually reviewed and designed new images for blog posts to replace the missing ones

 

In the end, we managed to recover about 70% of the media files. The remaining 30% were irretrievably lost, mostly blog-related images, which luckily didn’t affect user-critical functionality.

 

But this could’ve been much worse.

 

Key Lessons Learned (and You Should Too)

 

This story isn’t unique but the pain is very real. Here’s what we took away:

 

1. NEVER Use Production Data or Keys on a Dev/Test Server

 

Your dev environment should be completely isolated from production:

 

  • Different databases
     

  • Different file paths
     

  • Different environment variables (no production S3 bucket keys, please!)

 

2. Always Backup Before You Touch Deployment

 

Even for dev servers, if they carry any important or shared data, automate backups before any deployment. If the server is small, you can even create a quick tarball backup script.

 

“No one regrets having too many backups.”

 

3. Do Not Reuse Shared Infrastructure for Testing

 

Avoid using the same server (or shared folders) for both testing and production workloads. If resources are limited, at least use isolated containers, VMs, or mount points.

 

4. Enforce Review and Approval Process

 

Interns (and even full-time engineers) should always:

 

  • Submit deployment configuration changes through PRs.
     

  • Tag senior team members for review.
     

  • Confirm target environments and file paths before deploying.

 

5. Build a Safety Net Into CI/CD Pipelines

 

Add these safeguards:

 

  • Dry-run or staging mode before actual deployment.
     

  • Conditional deployment logic (if checks for branch, env, or directory).
     

  • Logging and alerts for file operations.

 

6. Document and Version Your Deployment Config

 

If something breaks, having version-controlled infrastructure lets you:

 

  • Trace changes quickly
     

  • Revert if needed
     

  • Learn from mistakes

 

Final Thoughts

 

DevOps isn’t just about automation - it’s about safe automation.

 

This incident reminded us how a tiny misconfiguration can ripple into huge data loss, even from the best intentions.

 

We’re grateful it was just blog images. But next time, it could be something worse.

 

Let this story be a cautionary tale and a checklist for your team.

 

Tag list:

Subscribe

Subscribe to our newsletter and never miss out lastest news.