Skip to content

orugari/shadow-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ShadowCopy Backup Script (PowerShell)

A simple PowerShell script that automates backup tasks using Windows Shadow Copy and Robocopy, with support for rotation and progress tracking.


Features

  • Creates a Shadow Copy of a selected volume
  • Uses Robocopy to copy only selected file types from specific directories
  • Supports multiple source directories
  • Displays a native Windows progress bar
  • Allows cancellation mid-process
  • Supports backup rotation (keeps N previous versions)
  • Cleans up shadow copy and symlink after execution

Requirements

  • Windows OS (with Volume Shadow Copy enabled)
  • PowerShell 5.1+
  • Admin rights required (to use vssadmin and mklink)
  • Robocopy (included in Windows)

🔧 Configuration

Inside the script, you can modify:

$VSV = "D:"                       # Volume to snapshot
$DIRSOURCE = @("\data\")       # Directories to back up (relative to root of volume)
$DIRDEST = "\\backup-nas\"    # Destination for backups (network path or local)
$EXT = "*.db"                    # File types to copy (use *.* for all)
$Shortc = "shadowcopy"           # Symlink name
$DELBCK = $true                  # Whether to delete shadow copy after run
$NBRBACKUP = 3                   # How many backup folders to retain
$MTNB = 8                        # Robocopy thread count

Example Usage

  1. Open PowerShell as Administrator
  2. Run the script:
    .\shadowcopy_backup.ps1
  3. Backups are saved in numbered folders (1, 2, 3, ...) inside the target directory.
  4. A log file is created automatically:
    backup_YYYY-MM-DD_HH-MM-SS.log

Cleanup

If $DELBCK = $true, the script will:

  • Remove the created symlink
  • Delete the shadow copy

If not, you’ll need to delete them manually using:

vssadmin delete shadows /for=D: /all /quiet
rmdir D:\shadowcopy

License

This script is provided under the MIT License.
Feel free to modify and adapt it for personal or professional use.


Credits

Created by orugari
Inspired by early backup batch techniques and modernized in PowerShell.

About

Backup your Disk with a simple and customizable batch script.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published