Offsite backup script (how do I create one?)

Long story short... I have a Synology NAS and need to create an offsite copy as simple and easily as possible. I would like to do this every Friday while I am in my office. I've tried using Synology's USB Copy (it sucks and doesn't work - takes way too long to a HD in a USB attached drive dock). I have too much data to upload to the cloud every day. USB is not the way... my network is the fastest copy option I have.

I have a Samsung 4 TB T9 SSD drive (portable) that I'll bring in and connect directly to my office desktop. I want to have a "script" or PowerShell Cmdlet that does the following:

\\NAS\SV1
\\NAS\SV2
\\NAS\SV3
\\NAS\SV4
\\NAS\FS1\Thursday

Why is there a Thursday? It would be the previous nights full image backup. For me to get all of the files to fit on 4 TB SSD I can only take ONE of the FS1 servers backup images. I have one for everyday, but this is solely for offsite purposes so I'd only need the previous nights backup. This makes the total amount of storage needed : 1.6 TB. I have a 4 TB so plenty of room :)

I can open a file explorer window with \\NAS and see all of the folders listed above. If I have my T9 mounted to drive letter Z (for example) how do I make exact copies of the network storage folders on the NAS?

I could manually do this by opening two windows side-by-side and copy/pasting, but I really want to be able to automate this so I can go about my day.

Any help is appreciated. I've always wanted to know more about scripting and this is probabily pretty straight forward and a good starting project to learn how to. Teach me the way :)
 

Oddabe19

Ars Tribunus Angusticlavius
6,847
Subscriptor
Robocopy or rsync. If using Robocopy you want the /MIR option so you only change what's been changed, making backups significantly quicker.

So:
Code:
robocopy /MIR <source> <destination> /r:5 /w:10
will copy only the data and files that have changed with 5 retries and 10 seconds in between each retry. And save as backup.bat (or something). Throw that in task scheduler for Thursdays at 1300 (or whenever) and forget about it.

If you want to get more detailed, add onto the bat script, by mounting your remote drive and folder first with
Code:
NET USE
, then move onto the backup script, and
Code:
NET USE /delete
afterwards to unmount drive.

https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy
You can exclude files and folder you don't want (i.e. %PROFILE%/.local/ or *.sys files for example).
 
I have been messing around with this today... Is there a way to mount a top level share via net use without specifying a folder?

i.e. net use \\backup\
and not \\backup\backup1

if I only use \\backup I get "system error 67 has occured" The network name cannot be found

However if I open File Explorer and type \\backup I can see all of the folders listed?

also... should I be using the /sec switch? these are windows system images so I would want the security to be preserved? The backup is being written to a T9 in exFAT so I don't know if that would even keep the /sec intact?