0

Everyone,

I'm trying to do a differential backup with svnadmin dump --incremental commmand. My idea is so basic, to read the multiple svn repositories using the command dir and to put into a text file called "input", to read it line by line and put into variables.
Get the last revision of the repositories with full backup script and write in a text file called "output" and put into a variables.
Everything is done, but I can't use the svnadmin dump because I need the variables (arrays) inside the loops. How can I do it? Please, help me, I tried so many times and doesn't work still ):

@echo off
cls
:: =================== CONFIG ============================================
:: Path of the dir containing your repos [Note Trailing slash]
SET repodir=E:\svn\repositorios

:: Path of the dir in which to create you dumps [Note Trailing slash]
SET repodump=E:\Backup\SVN

:: File to read (multiple directories)
SET "File2ReadInput=E:\Backup\SVN\input.txt"
SET "File2ReadOutput=E:\Backup\SVN\output.txt
SET "File2ReadOutputNew=E:\Backup\SVN\New\output_new.txt



:: =================== CONFIG ============================================
:: =================== SCRIPT ============================================

rem deleting old file output.txt
del E:\Backup\SVN\output.txt

rem deleting old file output_new.txt
del E:\Backup\SVN\New\output_new.txt

rem creating new file output.txt
for /f "delims=" %%f in ("E:\Backup\SVN\*.data") do type %%f >> E:\Backup\SVN\output.txt


rem creating input file
dir %repodir% /ad /b > E:\Backup\SVN\input.txt 

rem reading input file
setlocal EnableExtensions EnableDelayedExpansion
for /f "delims=" %%a in ('Type "%File2ReadInput%"') do (
    set /a count+=1
    set "Line[!count!]=%%a"
)

For /L %%i in (1,1,%Count%) do (
    echo "Var%%i" is assigned to ==^> "!Line[%%i]!"
    echo E:\svn\repositorios\!Line[%%i]!
    set REPO_NAME=!Line[%%i]!


:: getting new transactions to compare
    for /F "delims=" %%g in ('svnlook youngest E:\svn\repositorios\!Line[%%i]!') do ( 
        echo %%~g 

    ) > E:\Backup\SVN\New\last_rev_!Line[%%i]!_new.data

)

:: creating a new file with new datas
for /f "delims=" %%h in ("E:\Backup\SVN\New\*.data") do type %%h >> E:\Backup\SVN\New\output_new.txt

rem reading output file (dento do segundo for porque eu preciso do !Line[%%i]!)

setlocal EnableExtensions EnableDelayedExpansion
for /f "delims=" %%b in ('Type "%File2ReadOutput%"') do (
    set /a out_count+=1
    set "Output[!out_count!]=%%b"

)



for /L %%n in (1,1,%out_count%) DO ( 
    echo "Var%%n" is assigned to ==^> "!Output[%%n]:~0,-1!"
    set PREVIOUS=!Output[%%n]!
)   

for /F "delims=" %%u in ('svnadmin dump -r!Output[%%n]:~0,-1!:HEAD E:\svn\repositorios\!Line[%%i]! --incremental') do ( 
        echo %%~u 
)> > E:\Backup\SVN\svn_backup_diff_!Line[%%i]!.dmp
user138122
  • 11
  • 1
  • 1
    I suggest you to read [this answer](https://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script/10167990#10167990) – Aacini Feb 15 '19 at 20:17

1 Answers1

1

Without having seen fully through your code IMO lines 47..50 have an improper setting of the parentheses, try changing to:

(for /F "delims=" %%g in ('svnlook youngest E:\svn\repositorios\!Line[%%i]!') do echo %%~g  
) > E:\Backup\SVN\New\last_rev_!Line[%%i]!_new.data

An editor like Notepad++ helps to find/visualize corresponding pairs of parentheses.