For security reasons, the SVN server can do real-time backups in addition to regular full-scale backups and incremental backups, if conditions permit.
This requires 2 machines, one is master server and the other is mirror server. Master Service, mirror not external service or set read-only (except for synchronization account can write outside)
In addition, if the master load is relatively high, some read-only applications can be set to read from mirror, such as Jenkins compilation. (need to ensure real-time synchronization has been working)
The steps are as follows (for example, Linux sever):Add the following code snippet to Pre-revprop-change to allow Svnsync to overwrite the SVN library properties:
If ["$USER" = "Svnsync"]; Then exit 0; Fi
echo "Only the Svnsync user can change Revprops" >&2
SVN Real-time backup script, replacing Hook/post-commit in repo directory, requires Python support from the server
#!/usr/bin/python
#coding =utf-8
Import OS
Import commands
Import Sys
Import logging
def init_log (Log_level,logpath):
Logger = Logging.getlogger ()
‘‘‘
From logging.handlers import Rotatingfilehandler
Ro_hdlr=rotatingfilehandler (LogPath, maxbytes=0,backupcount=5)
Logger.addhandler (RO_HDLR)
Ro_hdlr.dorollover ()
‘‘‘
HDLR = logging. Filehandler (LogPath)
Formatter = logging. Formatter ('% (asctime) s [% (levelname) -8s% (module) s:% (Lineno) d]% (message) s ')
Hdlr.setformatter (Formatter)
Logger.addhandler (HDLR)
Logger.setlevel (Log_level)
return Logger
Repos=os.path.basename (Sys.argv[1])
Log=init_log (0, '/data/svnsynclog/' + repos + ' _sync.log ')
Log.info ("*" *20+repos)
Output=commands.getoutput ('/usr/bin/svnsync sync--non-interactive--username svnsync--password svnsync/http/ 10.0.80.21/svn/' +repos)
Log.info (' Sync log: ' +output)
Set Svnsync account has Read permission on master, read and write permission on mirror and then submit some change test, whether can synchronize the past in real time. Synchronized logs are placed in/data/svnsynclog (set to their own directory)
OK, Finish.
Manual sync commands from master to mirror:
Svnsync init--username svnsync http://10.0.80.21/svn/test http://10.0.80.20/svn/test
Svnsync Sync--username svnsync http://10.0.80.21/svn/test
SVN library real-time sync settings