Logo
RoboBackup: A Simple, Reliable Mirror Backup for Windows with PowerShell and Robocopy
share forum

RoboBackup: A Simple, Reliable Mirror Backup for Windows with PowerShell and Robocopy


Software • by Sven Reifschneider • 20 March 2025 • 0 comments

Because Reliable Backups Don’t Have to Be Expensive

I’m a strong advocate for simple solutions to seemingly complex problems—especially when it comes to backups. Linux users often rely on rsync to back up critical data to a NAS or external hard drive. But what’s the best alternative for Windows?

After some research and with a bit of help from ChatGPT, I developed a minimalistic yet highly robust backup solution using PowerShell and Robocopy.

This solution is perfect for those who:

Need a reliable backup tool for Windows

Want to avoid third-party software or subscription models

Require an rsync-like mirror backup using built-in Windows tools

Prefer a flexible, easily customizable solution with JSON-based configuration

In this guide, I’ll show you how to set up your own fully automated backup system using Robocopy and PowerShell—efficient, streamlined, and without unnecessary overhead.

Why Robocopy Is Perfect for This Backup Scenario

Robocopy (Robust File Copy) is a powerful command-line tool that has been around since Windows NT and remains a part of modern Windows versions. It offers several advantages over traditional copy methods:

  • Efficient mirror backups: Using /MIR, the destination folder is kept in perfect sync with the source, including deletions of files and folders that no longer exist in the source.
  • Delta copying: Only changed files are copied, saving both storage space and time.
  • Interruption resilience: The /Z option allows interrupted transfers to resume.
  • File and folder filtering: You can exclude specific files (e.g., temp logs or cache files) using exclusion lists.
  • Built-in error handling: Adjustable retry and wait times prevent failures due to temporary network issues or locked files (e.g., lock files).

With these features, Robocopy is the perfect choice for a simple yet powerful backup system that runs quietly in the background. I’ve been using this script for months without issues. While it may be slightly slower than dedicated backup tools, it runs efficiently in the background without requiring a constantly running program.

How the Backup Script Works

Solution Structure

My PowerShell backup system consists of three main components:

  1. backup.ps1 – The main script that performs the actual backup using Robocopy.
  2. backup_config.json – A configuration file defining which folders to back up, what to exclude, and when to run backups.
  3. backup_manage.ps1 – A management script that automatically creates a scheduled task in Windows Task Scheduler to run the backup at specified times.

Step-by-Step Setup

1️⃣ Download the Project

The complete script can be obtained from GitHub:

git clone https://github.com/neoground/robobackup.git
cd robobackup

Alternatively, download it as a ZIP file and extract it.

2️⃣ Adjust the Configuration File

The backup_config.json file contains the backup settings. Here’s an example:

{
    "taskName": "Periodic PowerShell Backup",
    "scriptPath": "C:\\robobackup\\backup.ps1",
    "triggers": [
        { "dayOfWeek": "Wednesday", "time": "13:00" },
        { "dayOfWeek": "Saturday", "time": "19:30" }
    ],
    "backups": [
        {
            "source": "C:\\Users",
            "destination": "\\\\192.168.1.1\\Backup\\Users",
            "excludeFiles": ["*.tmp", "*.log", "*.log.*", "NTUSER.DAT"],
            "excludeDirs": ["cache", "temp", "node_modules", "tmp", "*Temp*", "*Cache*", "Logs"]
        }
    ],
    "appListPath": "C:\\robobackup\\InstalledApps.txt",
    "logPath": "C:\\robobackup\\backup.log",
    "retryCount": 1,
    "waitTime": 1
}

Here, you can:

  • Define backup sources (source) and destinations (destination).
  • Exclude specific file types or folders from the backup.
  • Set a backup schedule using Windows Task Scheduler (triggers).
  • Customize paths, e.g., for storing a list of installed applications (appListPath) to speed up reinstalling software after a system crash.

If backing up to a network drive (NAS/Samba), use the network path as the destination instead of a mapped drive. Since JSON requires escaping backslashes, they must be doubled. In this example, the target is \\192.168.1.1\Backup\Users.

3️⃣ Run the Backup Script

You can manually start the backup via PowerShell:

.\backup.ps1

4️⃣ Automate It with Windows Task Scheduler

To schedule the backup, use the backup_manage.ps1 script:

.\backup_manage.ps1

This script creates a scheduled task that runs the backup based on the backup_config.json settings.

If you update your configuration, simply run the script again—it will update the task automatically.

The Robocopy Command in Detail

The core of the script is the following Robocopy command:

robocopyCommand = @(
    "robocopy",
    ""$source"",        # Source path
    ""$destination"",   # Destination path
    "/MIR",             # Mirror mode - exact sync
    "/COPY:DT",         # Copy data and timestamps only, no NTFS attributes
    "/E",               # Include all subdirectories
    "/S",               # Skip empty directories
    "/Z",               # Resume if interrupted
    "/NP",              # No progress output in logs
    "/XJ",              # Ignore symbolic links to avoid loops
    "/R:$($config.retryCount)", # Retry count for errors
    "/W:$($config.waitTime)"   # Wait time between retries
)

This setup ensures a reliable, incremental mirror backup, with ignored files and folders added dynamically.

Pro Tips for an Even Better Backup

💡 Save Windows Network Credentials

If backing up to a network drive, store credentials with:

cmdkey /add:192.168.1.1 /user:YourUsername /pass:YourPassword

I run the script as my standard user, with network drives already mapped in Windows Explorer. If running it as an administrator or system user, credentials must be stored separately.

💡 Use Winget for Software List Backups

I use winget to install and update software—it works great and fits my workflow, similar to apt on Debian.

After a system crash, having a list of installed programs is invaluable. The script saves this list with:

winget list > C:\robobackup\InstalledApps.txt

💡 Check Backup Logs

If a backup fails, check the log file. Its path can be adjusted in the configuration and contains the full Robocopy output.

Why This Solution Beats Many Commercial Alternatives

🚀 Fast & Efficient – No unnecessary software overhead, fully integrated into Windows

🔧 Maximum Control – Fully customizable via JSON

📡 Network-Ready – Perfect for NAS backups

🔄 Automated – Runs in the background without user intervention

I’ve tested many backup programs—none were as direct and efficient as this one. If you’re looking for a simple, reliable, and free way to back up your critical data, give RoboBackup a try.

The complete code and documentation are available on GitHub: neoground/robobackup.

Maybe this project helps someone out there—or even inspires you to create your own custom backup script!

This post was created with support from AI (GPT-4o). Illustrations were generated by DALL-E 3. Explore how AI can inspire your content – Neoground GmbH.


Share this post

If you enjoyed this article, why not share it with your friends and acquaintances? It helps me reach more people and motivates me to keep creating awesome content for you. Just use the sharing buttons below to share the post on your favorite social media platforms. Thank you!

Sharing Illustration
Donating Illustration

Support the Blog

If you appreciate my work and this blog, I would be thrilled if you'd like to support me! For example, you can buy me a coffee to keep me refreshed while working on new articles, or simply contribute to the ongoing success of the blog. Every little bit of support is greatly appreciated!

currency_bitcoin Donate via Crypto
Bitcoin (BTC):1JZ4inmKVbM2aP5ujyvmYpzmJRCC6xS6Fu
Ethereum (ETH):0xC66B1D5ff486E7EbeEB698397F2a7b120e17A6bE
Litecoin (LTC):Laj2CkWBD1jt4ZP6g9ZQJu1GSnwEtsSGLf
Sven Reifschneider
About the author

Sven Reifschneider

Greetings! I'm Sven, a tech innovator and enthusiastic photographer from scenic Wetterau, near the vibrant Frankfurt/Rhein-Main area. This blog is where I fuse my extensive tech knowledge with artistic passion to craft stories that captivate and enlighten. Leading Neoground, I push the boundaries of AI consulting and digital innovation, advocating for change that resonates through community-driven technology.

Photography is my portal to expressing the ephemeral beauty of life, blending it seamlessly with technological insights. Here, art meets innovation, each post striving for excellence and sparking conversations that inspire.

Curious to learn more? Follow me on social media or click on "learn more" to explore the essence of my vision.


No comments yet

Add a comment

You can use **Markdown** in your comment. Your email won't be published. Find out more about our data protection in the privacy policy.