Use Windows' robocopy
command to sync your files to the destination of your choice (e.g. OneDrive, Dropbox, etc.)
-
Download this repository:
git clone https://github.com/juangutierrez01/robocopy-backup-script
-
Open
settings.json
in a text editor and fill in thesource
anddestination
fields with the corresponding paths:{ "Backups": [ { "Name": "Example Backup", "Source": "C:\\Users\\YOUR_USER\\Documents\\ORIGINAL_FOLDER", "Destination": "C:\\Users\\YOUR_USER\\OneDrive\\BACKUP_FOLDER" } ], "LogDirectory": ".\\" }
-
Save your changes
-
Right-click on the file
robocopy.ps1
and selectRun with Powershell
to start backing up your files. To make it easier to run in the future, consider making a shortcut to the script as outlined in this guide: https://www.tenforums.com/tutorials/97162-powershell-scripting-run-script-shortcut.html
The underlying mechanism is the command, robocopy
:
robocopy "Source" "Destination" /log+:"LogFile" /tee /mir /z /j /mt:1
"Source" |
The directory you want to backup. |
"Destination" |
The path to your OneDrive/Dropbox/etc. |
"LogFile" |
The file to store the status output of robocopy. |
/tee |
Option to display the status output to the console window and store it in the log file. |
/mir |
Option to mirror the source directory tree. |
/z |
Option to copy files in restartable mode. In restartable mode, should a file copy be interrupted, robocopy can pick up where it left off rather than recopying the entire file. |
/j |
Option to copy files using unbuffered I/O. |
/mt:1 |
Option to create multi-threaded copies with 1 thread. |
See Microsoft's docs for details on the robocopy
command: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy