Jump to content

Continuous Replication between 2 sites


sbrassard

Recommended Posts

Hey guys,

I need some help with understanding replication. But first let me explain my request:

I would like to create a virtual machine to act as a replication server on the domain for PlasticSCM in the event that our current build box (currently acting as our central server for PlasticSCM) has some kind of critical failure which would require a rebuild to that server and basically bring my development team to a stand still for a few days (at least). We have backups that are happening daily at different times of day, but I thought of also using Plastic's capability of replication to provide my team basically zero downtime. This seems like a neat feature.

I would like to create an after-checkin trigger to replicate the changes in SiteA's repository to SiteB's repository. But it looks like there are some limitations or I dont fully understand how triggers work. It appears that I first have to create an after-checkin trigger that points to a batch file to get executed. But I want my batch to be as dynamic as possible and determine what branch the checkin is happening on and then push that branch's changes. In the below example, the branch being replicated is always /main. How can i make this dynamic instead of static in my batch file?

cm replicate br:/main@rep:default1@repserver:localhost:8084 rep:default2@repserver:192.168.0.108:8084

So, ideally, when a checkin happens, and if there is an after-checkin trigger, theoretically, Plastic *could* tell me on what branch that checkin happened. So maybe we can do something like this below, where the replicate command reads in my command and replaces #branch# with the name of the branch the checkin happened on:

cm replicate br:/#branch#@rep:default1@repserver:localhost:8084 rep:default2@repserver:192.168.0.108:8084

So, is this possible?

Thanks!

Link to comment
Share on other sites

Yep, you will need to write a script (batch files work fine) to do what you need, then tell Plastic to run it as an after-checkin trigger script.

Below is an after-checkin batch file I wrote, which calls a separate Perl script I created to do RCS-style keyword expansiion in each code file being checked in (one feature Plastic does NOT support!). This will get you pretty close to what you need I think; will need to be changed to act only on first file received in STDIN (since you only need to replicate once), and replace my cm commands and Perl script call with your replicate cm command listed above. I also like to write a "log" file for all scripts, you may want to remove that since the after-checkin script runs on the Plastic server?

The Plastic Triggers Manual has a good description of how to "hook up" these scripts to the trigger type you're interested in.

I'd play with this myself to get what you need, but too busy doing other work! :D

Hope this helps!

Dean

@echo off

set outfile=C:\PlasticCM\Triggers\Checkin-client.txt

set tmpfile=C:\PlasticCM\Triggers\Keyword.txt

set prlfile=C:\PlasticCM\Triggers\keyword_expansion.pl

echo ***Checkin Info*** > %outfile%

REM Get author of checkin from Plastic environment variable

set author=%PLASTIC_USER%

echo Author: %author% >> %outfile%

REM Get date/time of checkin

for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (

set currdate=%%a/%%b/%%c

)

for /f "tokens=1-2 delims=:" %%a in ('time /t') do (

set currtime=%%a:%%b

)

set currdatetime=%currdate% %currtime%

echo Date: %currdatetime% >> %outfile%

echo Files being checked in: >> %outfile%

:more_files

REM Parse revision identifiers for all items being checked in

REM from standard input and call routine to process keyword

REM expansion for file. Format of identifiers is as follows:

REM item_path#br:branch#rev_no;revid:rev_id@rep:rep_name@repserver:server:port

for /f "tokens=1-11 delims=#:;@" %%a in ('find /V ""') do (

call :process_file %%a %%c %%d %%f %%h %%j %%k

)

goto:EOF

:process_file

set source=%1

set branch=%2

set revno=%3

set revid=%4

set repo=%5

set server=%6

set port=%7

set revspec=revid:%revid%@rep:%repo%@repserver:%server%:%port%

set revision=%branch%#%revno%

echo source: %source% >> %outfile%

echo revision: %revision% >> %outfile%

echo revspec: %revspec% >> %outfile%

cm cat %revspec% --file=%tmpfile%

perl "%prlfile%" "%author%" "%currdatetime%" "%source%" "%revision%" "%tmpfile%" < "%tmpfile%"

cm shelve %revspec% --file=%tmpfile%

goto:EOF

exit 0

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...