<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pushing Pixels &#187; Perforce</title>
	<atom:link href="http://familywhitfield.co.uk/wordpress/category/software-development/perforce/feed/" rel="self" type="application/rss+xml" />
	<link>http://familywhitfield.co.uk/wordpress</link>
	<description>Computing and Digital Imaging</description>
	<lastBuildDate>Thu, 13 May 2010 20:13:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>A simple Perforce backup script for the home</title>
		<link>http://familywhitfield.co.uk/wordpress/2007/07/07/a-simple-perforce-backup-script-for-the-home/</link>
		<comments>http://familywhitfield.co.uk/wordpress/2007/07/07/a-simple-perforce-backup-script-for-the-home/#comments</comments>
		<pubDate>Sat, 07 Jul 2007 20:46:38 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Perforce]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[PC]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://familywhitfield.co.uk/wordpress/?p=24</guid>
		<description><![CDATA[I use the free license of Perforce on my home network just to ensure version control and management of home coding projects, university thesis stuff, and general files that I just want to ensure I have previous versions of. It&#8217;s a really nice part of the Perforce licensing model that I can get two users [...]]]></description>
			<content:encoded><![CDATA[<p>I use the free license of <a href="http://www.perforce.com">Perforce</a> on my home network just to ensure version control and management of home coding projects, university thesis stuff, and general files that I just want to ensure I have previous versions of. It&#8217;s a really nice part of the Perforce licensing model that I can get two users and five clients for free. My network has my main PC (with Perforce depot), my personal laptop, my wife&#8217;s laptop, and my work laptop all connected. It&#8217;ll get worse when my four-year old starts wanting to source control things from his PC!</p>
<p>Having been responsible for some pretty heavyweight Perforce installations in my working life, I did not want to forget the golden rule of checkpointing and backing up. While it would not be a disaster if my Perforce data got lost or messed up, it would be an inconvenience. The scripts published on Perforce user forums, however, tend to be focussed on industrial installations and can be quite complex. For the home it is nice to have something more simple.<br />
<span id="more-24"></span></p>
<p>So the script here is really aimed at the home user. I don&#8217;t use Perforce everyday at home, and so a nightly checkpoint and backup is a waste of time. I tend to run it every two to four weeks. My environment is that I have my main home PC running Perforce, and hanging off this on a USB-2 link is a Western-Digital MyBook external drive that shows itself as D: .  Sitting in the Perforce root folder (where the P4 db.* files are, and defined by the P4ROOT environment variable), I have a simple batch file called &#8220;backup.bat&#8221; (see code below).</p>
<p>The basic backup mechanism is this:</p>
<ol>
<li>Stop the Perforce server</li>
<li>Take a checkpoint</li>
<li>Copy checkpoint to a location on the MyBook external disk</li>
<li>Copy checkpoints to a location on the main PC &#8211; just duplication for safety</li>
<li>Delete checkpoints from P4ROOT</li>
<li>Use Robocopy to incrementally backup all depot files for each depot</li>
<li>Restart Perforce server</li>
</ol>
<p>Here&#8217;s the script. Just copy it into a .bat file put it into the P4ROOT folder. To run it, either do as a scheduled task or &#8211; as I do &#8211; just run it manually at whatever frequency you are happy with.</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">REM  *** Backs up Perforce</span>
p4 admin stop
p4d -jc -z
<span style="color: #b1b100; font-weight: bold;">copy</span> *.gz d:\Perforce\checkpoints
<span style="color: #b1b100; font-weight: bold;">copy</span> *.gz old_checkpoints
<span style="color: #b1b100; font-weight: bold;">del</span> /Q /F *.gz
<span style="color: #808080; font-style: italic;">rem *** now backup depot files. See following text for explanation</span>
robocopy depot d:\perforce\depotfiles\depot /S /E /MIR /R:<span style="color: #cc66cc;">1</span> /W:<span style="color: #cc66cc;">5</span> &amp;gt;robolog-depot.txt
robocopy perforce d:\perforce\depotfiles\perforce /S /E /MIR /R:<span style="color: #cc66cc;">1</span> /W:<span style="color: #cc66cc;">5</span> &amp;gt;&amp;gt;robolog-p4.txt
robocopy work d:\perforce\depotfiles\work /S /E /MIR /R:<span style="color: #cc66cc;">1</span> /W:<span style="color: #cc66cc;">5</span> &amp;gt;&amp;gt;robolog-work.txt
<span style="color: #808080; font-style: italic;">rem *** Restart server</span>
net start Perforce</pre></div></div>

<p>The three robocopy lines reflect that I have three depots on my server &#8211; &#8216;depot&#8217;, &#8216;perforce&#8217;, and &#8216;work&#8217;. Change these to reflect your own depots.</p>
<p>Robocopy is a free utility that runs under Windows that provides extremely flexible folder copy functionality. See the <a href="http://en.wikipedia.org/wiki/Robocopy">Wikipedia entry</a> for more details. Just make sure it is either on your search path, or place the EXE in the P4ROOT folder.</p>
<p>The options given to Robocopy just tell it to only copy files that are different to those that already exist. In otherwords, it synchronises one folder structure to another. I pipe the output into a log file so I can see exactly what new files have been copied if I need to.</p>
<p>And that&#8217;s it. Dead simple &#8211; will take you two minutes to set up, but could save you hours of hassle should something go awry in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://familywhitfield.co.uk/wordpress/2007/07/07/a-simple-perforce-backup-script-for-the-home/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Perforce server logging problem</title>
		<link>http://familywhitfield.co.uk/wordpress/2007/01/02/perforce-server-logging-problem/</link>
		<comments>http://familywhitfield.co.uk/wordpress/2007/01/02/perforce-server-logging-problem/#comments</comments>
		<pubDate>Tue, 02 Jan 2007 13:04:30 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Perforce]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://familywhitfield.co.uk/wordpress/?p=6</guid>
		<description><![CDATA[When setting up a server it is often useful to enable one of the logging levels. The admin guide states that you need to do this: p4 set P4DEBUG=server=2 which sets the server logging level to 2. You then need to restart the Perforce server. However, if Perforce is running as a service (the default [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span lang="EN-GB">When setting up a server it is often useful to enable one of the logging levels. The <a href="http://www.perforce.com/perforce/doc.061/manuals/p4sag/03_superuser.html#1079236" target="_blank">admin guide</a> states that you need to do this:</span></p>
<ul type="disc">
<li class="MsoNormal"><span lang="EN-GB">p4 set      P4DEBUG=server=2 </span></li>
</ul>
<p class="MsoNormal"><span lang="EN-GB"><br />
which sets the server logging level to 2. You then need to restart the Perforce server.</span></p>
<p>However, if Perforce is running as a service (the default under Windows), then this does not work. The reason is that &#8220;p4 set&#8221; only sets the variable in for HKEY_CURRENT_USER in the Windows registry. However, when running as a service, p4d picks up its environment variables from HKEY_LOCAL_MACHINE. To do this you need to set the &#8216;-s&#8217; flag. E.g.</p>
<ul type="disc">
<li class="MsoNormal"><span lang="EN-GB">p4 set -s      P4DEBUG=server=2 </span></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://familywhitfield.co.uk/wordpress/2007/01/02/perforce-server-logging-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
