The first is something you should do weekly on your Subversion repository – a full dump. Put the following in a BAT or CMD file on a Windows box, and run it scheduled.
@echo off
REM Creates a full dump of the repository, should be run weekly
for /f "tokens=1-4 delims=- " %%a in ('date /T') do set year=%%a
for /f "tokens=1-4 delims=- " %%a in ('date /T') do set month=%%b
for /f "tokens=1-4 delims=- " %%a in ('date /T') do set day=%%c
for /f "tokens=1-2 delims=: " %%a in ('time /T') do set hour=%%a
for /f "tokens=1-2 delims=: " %%a in ('time /T') do set minute=%%b
set TODAY=%year%%month%%day%
set NOW=%hour%%minute%
for /F "tokens=1 " %%i IN ('svnlook youngest c:\repository') do call set YOUNGEST=%%i
echo %YOUNGEST% > c:\backup\repository\latestRev.dat
svnadmin dump c:\repository > c:\backup\repository\svndump_full_rev%YOUNGEST%.%TODAY%%NOW%
The above example makes a dump to c:backuprepository of your repository at c:repository named with the most recent revision and todays date and time.
The example below creates incremental dumps using the latestRev.dat file to store the latest revision that was dumped.
@echo off
REM Creates a partial dump with all revisions since last full dump, should be run daily
for /f "tokens=1-4 delims=- " %%a in ('date /T') do set year=%%a
for /f "tokens=1-4 delims=- " %%a in ('date /T') do set month=%%b
for /f "tokens=1-4 delims=- " %%a in ('date /T') do set day=%%c
for /f "tokens=1-2 delims=: " %%a in ('time /T') do set hour=%%a
for /f "tokens=1-2 delims=: " %%a in ('time /T') do set minute=%%b
set TODAY=%year%%month%%day%
set NOW=%hour%%minute%
for /F "tokens=1 " %%i in ('svnlook youngest c:\repository') do call set YOUNGEST=%%i
set PREVIOUS=0
if not exist c:\backup\repository\latestRev.dat goto nolatestrev
for /F "tokens=1 " %%i in (c:\backup\repository\latestRev.dat) do call set PREVIOUS=%%i
:nolatestrev:
if %YOUNGEST% == %PREVIOUS% goto noupdate
echo %YOUNGEST% > c:\backup\repository\latestRev.dat
svnadmin dump -r %PREVIOUS%:%YOUNGEST% c:\repository > c:\backup\repository\svndump_incremental_rev%PREVIOUS%to%YOUNGEST%.%TODAY%%NOW%
goto finally
:noupdate
echo No dump needed
:finally
I’m no Windows batch file pro, but I got this working anyway with some help from Google.
Nice tool, gives some piece of mind. Would you have a Linux shell script version too?
Im running a Ubuntu installation at home with a Subversion repository but without any relevant data, but your question is interesting. After some searching, i found this script that I will try to implement sometime.
You can try the svn-backup-dumps in the subversion-tools package. I run it like this to get deltas from a repository for use with rsnapshot:
svn-backup-dumps -z -q --deltas -c 1000 /var/svn_repository .
Nice work, that’s just what I was looking for
I use %date% and %time% instead
SET month=%DATE:~4,2%
SET day=%DATE:~7,2%
SET year=%DATE:~-4%
SET hour=%TIME:~0,2%
SET minute=%TIME:~3,2%
What about the seconds? I mean, how can I do if I want to get the seconds too?
If you use Alis method, it should be something like:
SET seconds=%TIME:~6.2%