DEV Community

Alan Varghese
Alan Varghese

Posted on

"Bash Backup Battle: Minimalist vs. Feature-Rich Scripts"

In the world of automation, there's rarely a "one size fits all" solution. Sometimes you need a quick script to throw into a cron job, and other times you need a robust, configuration-driven tool that can handle remote transfers and detailed logging.

In this post, I’m comparing two Bash backup projects I've been working on. Both get the job done, but they take very different paths to get there.


The Contenders

1. The "DevOps-Ready" Script (file_backup_script)

This project is built for complexity and reliability. It treats configuration as code by separating the logic from the settings.

Key Features:

  • Configuration File (backup.conf): No need to touch the code to change paths or retention days.
  • Dry Run Mode (-d): A safety-first approach that tells you exactly what would happen without moving a single byte.
  • Remote Transfer: Built-in support for scp to push backups to a remote server.
  • Advanced Logging: Every action, warning, and error is timestamped and recorded in a dedicated log file.

2. The "Minimalist" Script (File_backup_scripts)

This project focuses on speed and simplicity. It’s the kind of script you can call on the fly from the terminal.

Key Features:

  • Argument-Driven: Pass your source and destination directly: ./backup.sh /src /dest.
  • Exclusion Patterns: Quickly skip .git folders or log files using glob patterns.
  • Automatic Cleanup: A hardcoded 30-day retention policy ensures your disk doesn't fill up.
  • Low Overhead: No config files to manage; just the script and your directories.

🔍 Feature Comparison

Feature DevOps-Ready Minimalist
Input Method Configuration File CLI Arguments
Remote Support Yes (scp) No (Local only)
Testing Dry Run Flag Manual
Multiple Sources Supported Single Source
Logging Detailed File Logs Standard Output
Complexity Medium Low

Which One Should You Use?

Use the DevOps-Ready Script if...

You are managing a server or a production environment. The Dry Run feature alone makes it much safer to deploy, and the Remote Transfer capability ensures your data is safe even if the local disk fails. It’s perfect for those who want to "set it and forget it."

Use the Minimalist Script if...

You need to grab a quick backup of a project folder before making major changes. It’s lightweight, requires zero setup, and handles the exclusion of messy folders like node_modules or .git with ease.


💡 Lessons Learned

Writing both of these taught me that context is king.

When I was building the DevOps version, I focused heavily on error handling and idempotency. I wanted to make sure that if a remote transfer failed, the script wouldn't just crash—it would log the error and move on.

With the minimalist version, the focus was on ergonomics. I wanted the shortest possible command to yield a reliable result.


Conclusion

Both scripts are available in my repository! Whether you need a robust automation tool or a quick-and-dirty backup utility, there's a Bash solution here for you.

Check out the code and let me know: Do you prefer config files or CLI arguments for your scripts?

https://github.com/alanvarghese-dev/Bash_Scripting

https://www.linkedin.com/in/alanvarghese-dev

Top comments (0)