Scheduler robocopy baclup script

WeegyAVLover

Distinguished Member
Joined
May 3, 2007
Messages
6,085
Reaction score
2,988
Points
1,872
Location
Scotland
Hi looking for some help with scripting and scheduling.

had a load of issues with my wife's itunes library over the years with it either filling up local hard drives, to moving it to a NAS share and connection issues with the NAS share meaning iTunes then reseting itself to a default location )very strange.

I have now got a laptop with storage that can handle her itunes to store it locally.
I do however want to back the iTunes music folder up to the NAS on a weekly or monthly basis.

When I was searching the web I found a suggestion to use powershell but after an initial dabble and it looking way harder to do stuff without know how to configure the powershell environment I have canned using that.

I know robocopy fairly well and found this article giving details on what to do:

however I have 3 queries on the simple script they are using:

@echo off
set X=<days>
set "source=C:\<Source Folder Path>"
set "destination=D:\<Destination Folder Path>"
robocopy "%source%" "%destination%" /mov /minage:%X%
exit /b

1) I do not understand what the days parameter is doing here, as they later set windows scheduler to run everyday at 6pm?
2) if I wanted the destination to folder to be something like - d:\itunes-yy-mm-dd (the date being the date of the copy). How would I do that?
3) the robocopy command would then be - robocopy /S "%source%" "%destination%" - yes?

Thanks
Col
 
Why not use SyncToy?
 
I will google that toot sweet but does that do what I need it to do via a graphical user interface?
Does that also take care of the scheduling or is windows scheduler still needed for that?

This will all be checked out after a bacon sarnie :D
Cheers
 
It has a GUI and can be run on a schedule.
 
for some reason I cannot install syncToy.
It needs a version of .Net Framework that is below what is already installed and I cannot install the older version.
Do not want to uninstall the current version as I am not sure what else potentially relies on that on my laptop.
 
There are a few different versions of SyncToy. Make sure you’ve the latest.
 
Ah.
 
I don't know PowerShell at all.

1) I do not understand what the days parameter is doing here, as they later set windows scheduler to run everyday at 6pm?

Only look at files DAYS old - ignore newer.

2) if I wanted the destination to folder to be something like - d:\itunes-yy-mm-dd (the date being the date of the copy). How would I do that?

$a = Get-Date -DisplayHint Date
$destination = "d:\itunes-"$a

??

Edit:

It is assumed robocopy will create the destination directory.
 
You can simply use this command from the command prompt:

Code:
robocopy [from-folder] [to-folder] /S

e.g

Code:
robocopy c:\apple\itunes\music \\mynas\itunesbackup\ /S

You definitely don't want to use MOV as that will delete the source after the copy is done - MOV is short for MOVE.

/S ensures it will copy all subdirectories (that are not empty)

You can schedule this with Windows Scheduler - have it run on a schedule, run on shutdown, etc.

This command will probably do the job. On some older systems the timestamp granularity is not great, so it copies the same files every time, however there are flags to get around this - if needed.
 
You can simply use this command from the command prompt:

Code:
robocopy [from-folder] [to-folder] /S

e.g

Code:
robocopy c:\apple\itunes\music \\mynas\itunesbackup\ /S

You definitely don't want to use MOV as that will delete the source after the copy is done - MOV is short for MOVE.

/S ensures it will copy all subdirectories (that are not empty)

You can schedule this with Windows Scheduler - have it run on a schedule, run on shutdown, etc.

This command will probably do the job. On some older systems the timestamp granularity is not great, so it copies the same files every time, however there are flags to get around this - if needed.
Yeah I wa aware of the /S switch and maybe I just leave the date thing, as having a recoverable copy is fine, even renaming it after the copy has completed manually is an option.

thanks
 
1. From what i can tell,
Robocopy will look at the "set X=<days>" value to determine if a backup is to take place.
The windows scheduler will just run that script every day for robocopy to check if it needs to run.


a command such as - mkdir itunes-%date:~-4,4%"-"%date:~-10,2%"-"%date:~7,2%
will create a folder called itunes with todays date (e.g. itunes-2020-18-02). but you would need to create this first, which you could probably add to the top of that script.
Though with windows scheduler, it would create a new folder every day the scheduler runs the script! :)
 
What NAS do you have ?
 
Use a freeware backup program? I use EaseUs ToDo Backup to back up my and my wife's PC's to a Synology NAS.

- there is a schedule option so the backups run every night
- a full backup once a week, incremental every other day
- the backup program accesses the NAS using a username which is the only one allowed to write to the backup share, so if we get a ransomware infection (which runs as the current logged-on user or the Administrator) it can't encrypt data on the backup share
- the backup share is synced to OneDrive so if both PC's and the NAS are stolen, the data is still safe.

For a quick-and-dirty backup you can also use Previous Versions which has the benefit that you don't need to install anything on the PC's to do recoveries.

I used to use Robocopy but there was no way I could find to provide ransomware protection.
 
Yeah I wa aware of the /S switch and maybe I just leave the date thing, as having a recoverable copy is fine, even renaming it after the copy has completed manually is an option.

thanks

No renaming should be necessary. The above command will be repeatable - most likely each subsequent execution will only copy new files.
 

The latest video from AVForums

Is 4K Blu-ray Worth It?
Subscribe to our YouTube channel
Back
Top Bottom