Skip to content

A Windows Powershell script, batch file and sheduled task to automatically backup a usb drive to a machine when it is inserted (based on monotone's script)

License

Notifications You must be signed in to change notification settings

SkalyptoSama/USB-drive-backup-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

USB-backup

Windows PS Script and .bat to automatically backup a usb drive to a machine when it is inserted (based on monotone's script). Sources below.

Set up

To set up the automatic backup download Sync.bat, USB-backup.ps1 and USB-backup.xml

The batch file should go at the root your usb drive and the PS script can go anywhere you want on your machine.

Open Sync.bat with a text editor and change the backup folder path.

image

Same with USB-backup.ps1 and change 'Mirror' to your drive name.

image

Then in Windows Task Scheduler, select import task and open USB-backup.xml

Go to 'Actions' and 'Modify' and in the 'Arguments' delete whats after -File and enter the full path to USB-backup.ps1

image

You can also remove -WindowStyle Hidden if you want to see the powershell window.

image

The -ExecutionPolicy Bypass argument allows the script to run.

Sources

Monotone's script can be found here :

https://answers.microsoft.com/en-us/windows/forum/windows_vista-windows_programs/task-scheduler-how-to-automatically-synchronize-my/45a49d83-b1d8-4d37-8896-3d2696cf9795

image

image

Their work is based on these blog posts :

https://devblogs.microsoft.com/scripting/hey-scripting-guy-can-i-be-informed-when-a-portable-drive-is-added-by-my-computer/

https://devblogs.microsoft.com/scripting/hey-scripting-guy-can-i-format-a-portable-drive-when-it-is-inserted-into-a-computer/

About

A Windows Powershell script, batch file and sheduled task to automatically backup a usb drive to a machine when it is inserted (based on monotone's script)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published