script to backup to synology


Author
Message
johnb263
johnb263
New Member
New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)
Group: Forum Members
Posts: 2, Visits: 8
Hi, I've mapped a synology NAS folder to windows explorer. Running Macrium 8 with vbs-script as in attached file.
The script works 100% if I'm logged into windows with my admin username.
However I have my PC off most of the time - I've set the Synology to wake up the pc at 12:45am - since I'm not logged in, the script needs to run as a service. I've scheduled macrium to start the script 15mins later than the pc wakeup time (at 1 am).
The script runs 5 definition files,
There are two parts to the script for the first 4 of the definition files :-
1. Run the definition file, which will backup a drive (or files/folders) to a disk local to the PC.
2. Then, after each definition file is done,  do robocopy for the backup directory to the mapped synology drive.
The last definition file copies synology files/folders to a PC drive. So, no robocopy for this one.
Part 1 works fine, logged in or not.
For part 2 to work, I need to be logged in. So, it wont run with my 1a.m. effort.
In trying to get this to work, I saw some post where someone mentioned to try and add  "net use /delete \\JB_DS220_32TB\DS220_Backups" (where the last is my backupu directory on the NAS) - but the script will not run at all with this. I've set the NAS logon credentials in Macrium's options, and it checked OK.
Any help would be much appreciated
Thanks




jphughan
jphughan
Macrium Evangelist
Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)Macrium Evangelist (22K reputation)
Group: Forum Members
Posts: 14K, Visits: 84K
The issue is Robocopy. The NAS credentials you’re storing in Reflect are only available to Reflect. They won’t be available to Robocopy after Reflect exits, so Robocopy won’t have an authenticated connection open to the NAS at that point. When you run the script while logged in, the script executes in your user context, which I presume already has such a connection open, in which case Robocopy can piggyback on that. But tasks that run in the background run in a separate context, and Windows does not allow authenticated connections to be shared across contexts.

Modify the script to open its own NAS connection after Reflect completes, before Robocopy runs. I grant that since you’re trying to run several definition files in a single script and perform synchronization after each job rather than stacking the Robocopy jobs at the end, that might be somewhat arduous — unless you’re willing to change that design. Either way, you’ll need to store NAS credentials in the script.

And if you want better security, consider creating an entirely separate share (not folder) on your NAS purely for Reflect backups. Store read/write credentials in Reflect and your script, but use read-only credentials in your user session except for the times when you specifically need to modify backups from within Windows. That way if ransomware ever makes its way onto your system, it won’t see a nice bridge over to your NAS with read/write privileges to allow it to destroy your backups. To make this design practical for on-demand backups, choose to run even your manually invoked backups in the background.
Edited 12 September 2023 4:15 AM by jphughan
johnb263
johnb263
New Member
New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)
Group: Forum Members
Posts: 2, Visits: 8
Seems my answer post did not post - Thanks for the reply. It makes sense - if I use a definition file to copy to the NAS, it works fine. I wanted to switch to Robocopy since it's faster. Guess I'll stick with definition files. I'll also look into creating a seperate share for backups with it's own credentials.


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Login

Explore
Messages
Mentions
Search