Automating a Synchronization

I wanted to sync our Dev Web site with our Prod Web site.
The idea was to move new files into the Prod site and delete any old or extra files.
Rather than write a POSH script I decided to use Beyond Compare 3. Great product, I highly recommend it.
With some help from the folks at Scooter Software, I came up with this:

###### Start Posh Script ########

Function Show-Inputbox {
 Param([string]$message=$(Throw "You must enter a prompt message"),

 [reflection.assembly]::loadwithpartialname("microsoft.visualbasic") | Out-Null


$Dev = Show-Inputbox -message "The New Web files location" `
-title "Path" -default "E:\DevSite\0000\"

$Prod = Show-Inputbox -message "The Prod Web files location" `
-title "Path" -default "E:\inetpub\0000\"

$left = $Dev
$right = $Prod

$exe = "E:\Tools\BEYOND~1\BCompare.exe"
$p = [diagnostics.process]::Start("cmd.exe", "/c start /wait " + $exe + " @E:\Scripts\PS1\IISProject\SyncWebSite.txt $left $right")

############# End POSH Script ###############

You also need to write a simple text file up that includes the parameters for BeyondCompare like this:

# Keeping a web site in sync
# This script keeps a web site in sync with development files.
# Turn verbose logging on.
log verbose append: “E:\WebSyncLog\%date%.txt”

# be carefull with the Quote marks, You may need to change them
# Set the comparison criteria.
criteria binary size
# Load source and target folders.
load %1 %2
# Filter to only include source files, ignore CVS subfolders.
# filter “*.htm;*.html;*.php;*.jpg;*.gif;-CVS\”
# Sync the local files to the web site, creating empty folders.
sync create-empty mirror:left->right
I called it SyncWebSite.txt

Be very carefull with your left and right directories.
Once it’s synced there is no going back.


13 thoughts on “Automating a Synchronization

  1. Thank you for the sensible critique. Me and my neighbor were just preparing to do some research on this. We got a grab a book from our area library but I think I learned more clear from this post. I’m very glad to see such fantastic information being shared freely out there.

  2. I must show my thanks to this writer for rescuing me from this problem. Just after browsing throughout the internet and getting concepts that were not beneficial, I thought my entire life was gone. Living without the approaches to the problems you’ve sorted out by way of your good review is a crucial case, and those that could have in a wrong way damaged my entire career if I had not discovered your website. Your good understanding and kindness in controlling almost everything was excellent. I am not sure what I would have done if I had not come upon such a step like this. I am able to now look forward to my future. Thanks for your time so much for the reliable and effective guide. I will not be reluctant to suggest your blog post to any individual who needs to have guidelines on this topic.

  3. I simply wanted to thank you so much once again. I’m not certain what I might have created in the absence of the type of advice documented by you on such concern. Previously it was a real depressing difficulty in my opinion, but understanding this specialised way you dealt with that forced me to leap for joy. Now i’m happy for the work and in addition trust you are aware of a powerful job you are always accomplishing teaching the others with the aid of your websites. Most probably you haven’t got to know all of us.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s