I pilfered a script from elsewhere on this site (see below) which works almost perfectly, the only issue is that it doesn't go into the sub-directories of the destination.
If P:\test1.txt is updated, the next backup will create Z:\test1.txt.v1, leaving the previous in place
If P:\test\test1.txt is updated, the next backup will do nothing to that file.
I'm sure it's something simple I'm missing but I can't find any parameters in the xcopy manual and trying things like *\ in the destination hasn't helped
@echo off setlocal REM Source and destination paths. Do not include a trailing backslash. set source=P:\Backup set dest="Z:" REM The maximum number of backups to create for each file. set max=100 robocopy "%source%" "%dest%" /ZB /XC /XN /XO /R:3 /W:3 /E > report.txt for /F "tokens=*" %%G in ('robocopy "%source%" "%dest%" /XX /L /NDL /NS /NC /NJH /NJS') do ( call :_process "%%G" ) C:\Backup\blat310\full\blat.exe report.txt -to firstname.lastname@example.org -u user -pw password -s "backup report" copy report.txt C:\Backup\logs\*_%date:/=%_.txt del report.txt goto :eof :_process set counter=1 set file=%~n1 set ext=%~x1 :_loop if exist "%dest%\%file%v%counter%%ext%" ( set /A counter+=1 goto :_loop ) if %counter% GEQ %max% ( echo %file%%ext% not copied. Maximum number of backups already created. goto :eof ) echo F|xcopy %1 "%dest%\%file%v%counter%%ext%" /C /H /R /Z /E /S goto :eof