SVN library real-time sync settings

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.