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 • von Sven Reifschneider • 20. März 2025 • 0 Kommentare
info
Dieser Beitrag ist auch auf Deutsch verfügbar. Auf Deutsch lesen

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.


Teile diesen Beitrag

Wenn dir dieser Artikel gefallen hat, teile ihn doch mit deinen Freunden und Bekannten! Das hilft mir dabei, noch mehr Leute zu erreichen und motiviert mich, weiterhin großartige Inhalte für euch zu erstellen. Nutze einfach die Sharing-Buttons hier unten, um den Beitrag auf deinen bevorzugten sozialen Medien zu teilen. Danke dir!

Sharing Illustration
Donating Illustration

Unterstütze den Blog

Falls du meine Arbeit und diesen Blog besonders schätzen solltest, würde ich mich riesig freuen, wenn du mich unterstützen möchtest! Du kannst mir zum Beispiel einen Kaffee spendieren, um mich bei der Arbeit an neuen Artikeln zu erfrischen, oder einfach so, um den Fortbestand des Blogs zu fördern. Jede noch so kleine Spende ist herzlich willkommen und wird sehr geschätzt!

currency_bitcoin Spende via Kryptowährungen
Bitcoin (BTC):1JZ4inmKVbM2aP5ujyvmYpzmJRCC6xS6Fu
Ethereum (ETH):0xC66B1D5ff486E7EbeEB698397F2a7b120e17A6bE
Litecoin (LTC):Laj2CkWBD1jt4ZP6g9ZQJu1GSnwEtsSGLf
Sven Reifschneider
Über den Autor

Sven Reifschneider

Herzliche Grüße! Ich bin Sven, ein technischer Innovator und begeisterter Fotograf aus der malerischen Wetterau, in der Nähe des lebendigen Frankfurt/Rhein-Main-Gebiets. In diesem Blog verbinde ich mein umfangreiches technisches Wissen mit meiner künstlerischen Leidenschaft, um Geschichten zu erschaffen, die fesseln und erleuchten. Als Leiter von Neoground spreng ich die Grenzen der KI-Beratung und digitalen Innovation und setze mich für Veränderungen ein, die durch Open Source Technologie Widerhall finden.

Die Fotografie ist mein Portal, um die flüchtige Schönheit des Lebens auszudrücken, die ich nahtlos mit technologischen Einsichten verbinde. Hier trifft Kunst auf Innovation, jeder Beitrag strebt nach Exzellenz und entfacht Gespräche, die inspirieren.

Neugierig, mehr zu erfahren? Folge mir in den sozialen Medien oder klicke auf "Mehr erfahren", um das Wesen meiner Vision zu erkunden.


Noch keine Kommentare

Kommentar hinzufügen

In deinem Kommentar kannst du **Markdown** nutzen. Deine E-Mail-Adresse wird nicht veröffentlicht. Mehr zum Datenschutz findest du in der Datenschutzerklärung.