How do I back up a remote SVN repository

后端 未结 9 672
生来不讨喜
生来不讨喜 2020-12-22 20:28

I am currently moving my SVN server from my home server to my remote server so I can access it more easily from other locations. My remote server is not backed up so I want

相关标签:
9条回答
  • 2020-12-22 20:34

    create your local repository

    svnadmin create /Users/jsmith/repo

    create an empty pre-revprop-change hook script

    echo '#!/bin/bash' > /Users/jsmith/repo/hooks/pre-revprop-change

    make the pre-revprop-change hook script executable

    chmod +x /Users/jsmith/backup/hooks/pre-revprop-change

    initialize svnsync

    svnsync init file:////Users/jsmith/repo https://www.smith.com/repo

    synchronize repos

    svnsync sync file:////Users/jsmith/repo

    0 讨论(0)
  • 2020-12-22 20:39

    To expand on Stefans answer, here are some windows batch scripts to help automate the process a little.

    svn-backup-init.bat

    @echo off
    set /P directory="Local Directory: "
    set /P URL="Svn URL: "
    
    echo "Running SVN backup";
    
    @echo on
    svnadmin create %directory%
    echo exit 0 > %directory%\hooks\pre-revprop-change.bat
    svnsync init file:///%directory% %URL%
    svnsync sync file:///%directory%**strong text**
    

    This script will create the svn repo, and check it out and do a sync immediately. When you run the script just enter the directory to put the repo locally and the URL of the server to use.

    svn-backup-run.bat

    for /d %%i in (%~dp0*) do ( svnsync sync file:///%%i ) 
    

    This will loop through each directory and run the svnsync command. If you have multiple repos, check them out into the same folder. This can then easily be added as a Task in windows to update all your repos at once.

    Folder Structure

    I use a folder structure as such:

    .
    ├── svn-backups
    |   ├── repo-1
    |   ├── repo-2
    |   ├── repo-3
    |   ├── svn-backup-init.bat
    |   └── svn-backup-run.bat
    
    0 讨论(0)
  • 2020-12-22 20:41

    I would use either svnsync or svnadmin hotcopy as both of these techniques are guaranteed to copy valid data from the repository, even if a transaction is in progress. Other file synchronisation techniques may not be as reliable, depending upon the repository format.

    0 讨论(0)
  • 2020-12-22 20:42

    As of subversion 1.7, you can also use the new command svnrdump. From the docs:

    Dump—that is, generate a repository dump stream of—revisions of the repository item located at SOURCE_URL, printing the information to standard output.

    Usage would be:

    svnrdump dump http://example.com/repos/ > repos.dump
    

    This creates a "dump file" of the repository in repos.dump. This is a complete backup of your repository data including history, but is not directly readable by a subversion client. If you need to restore this data, use the standard svnadmin tools:

    svnadmin create c:\backup-repos
    svnadmin load c:\backup-repos < repos.dump
    

    Haven't done any testing, but this might end up being slower than svnsync. svnrdump will do a complete dump of the repository everytime, where I'm assuming synsync will only import changes in the repository since the last time it was run. You will have a single file containing your entire repository though, which may or may not be easier to manage.

    Note that you may want to pipe the output of svnrdump through gzip or similar program to possibly significantly reduce the size of the outputted file.

    0 讨论(0)
  • 2020-12-22 20:44

    rsync (or DeltaCopy which is a Windows UI on top of it) would be a good choice to incrementally copy the complete repository at the filesystem level.

    You can also use svnsync to copy new revisions directly from one SVN server to another.

    0 讨论(0)
  • 2020-12-22 20:46

    You can use a script on a remote server which dumps the repository, then copies it to your local computer (or leaves it in a predefined location for your local computer to copy)

    You can either sync the backup directories with rsync or scp.

    The script can be run with "Scheduled Tasks" and can produce uniquely named backup files, which will later by synced in the above mentioned way by your local computer. (and then possibly deleted)

    0 讨论(0)
提交回复
热议问题