Operation Flow:1. Build the repository on the machine to be backed up: svnadmin Create Test 2, go to hooks directory: CD TEST/HOOKS/3, create Pre-revprop-change file: CP Pre-revprop-change.tmpl Pre-revprop-change 4, modify Pre-revprop-change permissions: CHOMD +x pre-revprop-change
5. Modified File: VI Pre-revprop-change
For echo "Changing revision properties other than Svn:log is prohibited" >&2
Exit 0 (1 modified to 0) 6, synchronous preliminary:
Svnsync Init file:///home/test/svn/test SVN://10.10.10.1/
Svnsync:destination Repository is already synchronizing from ' Svn://10.10.10.1′7, implementing synchronization:
Svnsync Sync file:///home/test/svn/test–username Username–password password1
Problems and Workarounds:
Question 1
Failed to get lock on destination repos, currently held by ' BUG1.CORP.SCMBBS.COM:0C424C20-2E3B-0410-BD34-7FDD53C25D02 ' C0/>svnsync:couldn ' t get lock on destination repos after ten attempts
At this point, the attribute may be locked and the attribute deleted:
SVN propdel svn:sync-lock--revprop-r0 File:///home/backup/svn/svnsync/SMP
After the deletion succeeds, try again the basic is possible.
If the repeated operation is the same error, there may be a problem with your SVN installation, reinstall it again, that's it.
Question 2
[Test@localhost sync]$ svnsync sync file:///home/test/svn/test--username username
--password
username123 Svnsync:destination HEAD (593) is not the last merged revision (592);
Has the committed to the destination without using Svnsync?
< search results >
It looks like Svnsync committed up through R35, but somehow it didn ' t-track this in its ' svn:sync-last-merged-revision ' PR Operty, which is still lagging at 30. Just Modify, Revision 0 to be: $ svn proplist-v--revprop-r0 HTTPS://POWERMOCK.GOOGLECODE.COM/SVN $ s VN propset--revprop-r0 svn:sync-last-merged-revision HTTPS://POWERMOCK.GOOGLECODE.COM/SVN then you should being able to
Keep syncing. [Test@localhost sync]$ svn proplist-v--revprop-r0 file:///home/test/svn/test--username username--password username12 3 unversioned Properties on revision 0:svn:sync-from-uuid:729778b4-f309-46d9-b0ab-184bf13f9df8 SVN: sync-last-merged-rev:592 svn:date:2008-11-25t04:02:56.364852z svn:sync-from-url:svn://10.10.10.1 [Test@localhost s ync]$ svn propset--revprop-r0 svn:sync-last-merged-revision 593 file:///home/test/svn/test Property ' SVN: Sync-last-merged-revision ' Set on repository revision 0 test@localhost sync]$ svn propset--revprop-r0 svn:sync-last-mer Ged-rev593 fi le:///home/test/svn/test Property ' Svn:sync-last-merged-rev ' set on repository revision 0 [Test@localhost sync]$ s
Vnsync Sync file:///home/test/svn/test--username username--password username123 Committed revision 594.
Copied Properties for revision 594. Svnsync:expected ' revprops ', found ' failure '
Related Introduction
This article describes the use of Svnsync to synchronize the repository, to achieve the purpose of backing up the repository
There are two commands to use.
1. Svnsync Init
Initialize, establish a synchronization relationship between the target library and the source library
Command format svnsync init target library URL Source Library URL
2. Svnsync Sync
True synchronization
Command format svnsync sync target library URL
Goal
This implementation is the remote automatic backup of the repository, backup the repository to another machine
Suppose we want to synchronize the source repository for http://192.168.0.1/svn/proj1 located at machine A, the specific path we don't have to ignore because we use the HTTP protocol
Target library in Machine b,file:///svn/proj1, this for simplicity and security, we use the file://protocol, PROJ1 is an empty library we created with the svnadmin create command
Process
1. On machine B, create the target library
Mkdir/svn
Svnadmin create/svn/proj1
2. On machine B, modify the script of the target library Pre-revprop-change
Enter/svn/proj1/hooks/
cd/svn/proj1/hooks/
CP Pre-revprop-change.tmpl Pre-revprop-change
chmod +x Pre-revprop-change
VI Pre-revprop-change
Repos= "$1″
rev= "$2″
User= "$3″
Propname= "$4″
Action= "$5″
If ["$ACTION" = "M"-a "$PROPNAME" = "Svn:log"]; Then exit 0; Fi
echo "Changing revision properties other than Svn:log is prohibited" >&2
Exit 1
The original script means that if you modify the Svn:log property, it will allow the modification to return 0; otherwise, it is not allowed to return 1
We want to change it to allow all properties to be modified, return 0 directly in the script, the new script is as follows:
Exit 0;
3. Initialization
On machine B.
Svnsync init file:///svn/proj1 http://192.168.0.1/svn/proj1 will prompt for a user name and password, the user name and password provided here are fully readable http://192.168.0.1/svn/ PROJ1 User name and password
4. Synchronization
On machine B.
Svnsync Sync file:///svn/proj1
You will still be prompted for your username and password, but you can add the username, password parameters after this command,
For example svnsync sync file:///svn/proj1–username username–password Password official notes
= = = What's It? ====
Svnsync is a tool for creating and maintaining read-only mirrors of
Subversion repositories. It works by replaying commits that occurred
In one repository and committing it into another.
= = Basic Setup = = = =
First, you need to create your destination repository:
$ svnadmin Create Dest
Because Svnsync uses Revprops to keep track of bookkeeping information
(And because it copies revprops from the source to the destination)
It needs to is able to change revprops on your destination repository.
To does this you'll need to set up a pre-revprop-change hooks script that
Lets the user you'll run Svnsync as make arbitrary propchanges.
$ cat << ' EOF ' > Dest/hooks/pre-revprop-change
#!/bin/sh
User= "$3″
If ["$USER" = "Svnsync"]; Then exit 0; Fi
echo "Only the Svnsync user can change Revprops" >&2
Exit 1
Eof
$ chmod +x Dest/hooks/pre-revprop-change
$ svnsync init–username svnsync file://' pwd '/dest \
Http://svn.example.org/source/repos
Copied Properties for revision 0
$
Note that the arguments to ' svnsync init ' is the arbitrary repository
URLs. The first is the destination, which must be empty, and the second
is the source.
Now you can just run the ' svnsync Sync ' command to synchronize pending
Revisions. This would copy any revisions, exist in the source repos
But don ' t exist in the destination repos.
$ svnsync Sync file://' pwd '/dest
Committed Revision 1.
Copied Properties for Revision 1.
Committed Revision 2.
Copied Properties for revision 2.
Committed Revision 3.
Copied Properties for Revision 3.
...
= = = Locks = =
If you kill a sync while it's occurring there ' s a chance that it might
Leave the Repository "locked". Svnsync ensures that's only one Svnsync
Process is copying data to a given destination repository at a time
By creating a Svn:sync-lock revprop on revision zero of the destination
Repository. If is there and you ' re sure no svnsync are
Actually running, you can unlock the repository by deleting that revprop.
$ svn pdel–revprop-r 0 svn:sync-lock file://' pwd '/dest
= = = FAQ = =
Q:so what can I do with this thing anyway?
A:Well, anything that ' s read-only. As long as you don ' t commit changes
To the destination repository your ' re all set. This means destination
Repositories is good for providing offsite mirrors, read-only mirrors,
etc.
Q:What if I want to check out from a mirror, but is the commit to the master?
A:That ' s possible, but requires some gymnastics. You see, each repository
Have its own UUID, which are stored in the working copy, so if you check
Out from the mirror, and then does a ' svn switch–relocate ' to point to
The master it ' ll error out. Need to make sure that
The mirrors has the same UUID as the master. You can read a repository
UUID with ' svnlook uuid ' or ' svn info ', and change it with
' Svnadmin setuuid '.
Once both the mirror and master repositories has the same UUID you can
Safely check out from the mirror and commits to the master, all of them have
To-do-a ' svn switch–relocate ' to-point your working copy to the
Master before a commit.
Note that you should never commit changes to a mirror other than
Via Svnsync, so-to-avoid accidentally doing so if want to add
A start-commit hook script that disallows commits from the users other
than the one you run Svnsync as, and a pre-lock hooks script that
Disallows all FileSystem lock requests (Svnsync would never create
These locks, but it attempt to commit can is blocked by them).
Q:What version of Subversion is required to use Svnsync?
A:The source repository must be running Subversion 1.4 or newer, since
Svnsync uses a new RA layer command that is added in 1.4. On the other
Hand, the destination repository can be any version of Subversion, since
All Svnsync are doing is committing changes using the regular RA APIs.
Q:do I need to run Svnsync on the same machine as one of the
Repositories?
A:while need direct access to the destination repository to
Set up a pre-revprop-change hooks script, after then point Svnsync
Communicates with both repositories through the same "repository
Access "layer that SVN uses to connect to remote repositories. So
Svnsync does not has the to is run on the same machine as either
Repository It can communicate with both repositories over any of
Subversion ' s RA protocols (svn://, svn+ssh://,/http, https://,
or file:///). In fact, you don ' t need any special permissions on
The source repository at all.
Q:How does svnsync deal with parts of the master repository which I ' m not
Authorized to read?
A:svnsync would simply not copy parts of the repository
Cannot read; Files copied from "Private" parts of the repository
into "public" parts would look as if they has been added from
Scratch. If A revision only modifies files, then you cannot read,
It'll appear to be empty. (Just like with "SVN log", log
Messages from revisions your cannot read part of'll be empty.)
Q:Can I Mirror A subdirectory of a master repository?
A:As of Subversion 1.5, it is possible to the limit Svnsync to a subdirectory
of the Master repository.
Useful when the master repository was organized in projects,
And you want to sync only one project.
Example showing Svnsync of Project1 in the Master repository:
/project1
/branches
/tags
/trunk
/project2
/branches
/tags
/trunk
The following commands would sync all changes in/project1 to the target
Repository
$ svnsync init file://' pwd '/dest http://svn.example.org/source/repos/project1
$ svnsync Sync file://' pwd '/dest
Note:this syntax only allows your to limit the scope of Svnsync to
/project1. It does not:
-Allow you to sync double or more projects from the Master repository.
-Recognize renames of Project1. Example, if the original name of Project1
Was Secretproject, only the changes starting from the revision in which the
Rename to Project1 was committed would be synced.
If you need any of the these abilities right now, your may want to look into SVK
(http://svk.bestpractical.com/).
Q:What happens when am I change a revprop on the master server?
A:That depends, did your change it on A revision so had already been
mirrored or one that's still waiting to be Mirrored. If the revision
hasn ' t been mirrored yet, the new revprop would just get copied across
normally when the next sync Happens. If not, then you ' ve got a small
problem. You see, since revprops aren ' t versioned, there's no-to-
detect (via the Subversion RA APIs anyway) that it ' s been Changed, so
the next time you run a sync svnsync have no-to-tell-it has
changed. There is a-on-the-you-to-build your own solution though,
just use the ' svnsync copy-revprops ' command. The usual technique is
either-put an explicit-to-it in your master repository ' s
Post-revprop-change script , or to has the Post-revprop-change script
Record The fact that a change occurred, and then later on has some
Jo b Look through the list of changes and copy them to you.
Q:How can I relocate the source repository for Svnsync?
A:A simple-to-relocate A svnsync-ed repository is-to-change the
Revision property (of the mirror) that stores the source repository ' s
Url. Just Use the This command:
$ svn propset svn:sync-from-url–revprop-r 0 new_source_url Mirror_url
Note:don ' t use ' svn propedit ', because editors could append an EOL
Character to New_source_url that'll lead Svnsync complaining
"Svnsync:malformed URL for Repository".