Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » Utilities » Downloads
 
Add your own
alternative version

PostgreSQL Synchronization Tool

, 19 Aug 2009
Idea and implementation of a simple and easy database synchronization tool.
psync.zip
npq
npq
npq.userprefs
npq.usertasks
bin
Release
npq.dll
npq.pidb
psync
bin
Release
npq.dll
psync.exe
psync.pidb
/* psync - A PostgreSQL synchronization tool
 * 
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the "License").  You may not use this file except
 * in compliance with the License.
 *
 * You can obtain a copy of the license at
 * http://www.opensource.org/licenses/cddl1.php.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * Copyright 2009 by martin.faust@e56.de
 */
using System;
using npq;

namespace psync {
	class MainClass {
		public static void usage() {
			Console.WriteLine("--incrementatal  Incremental backup. Only new tables are sync'd (default)");
			Console.WriteLine("--complete       All tabled are sync'd");
			Console.WriteLine("--source         The source config (PostgreSQL connection string)");
			Console.WriteLine("--destination    The destination confing (PostgreSQL connection string)");
			Console.WriteLine("--delete         Delete tables on destination that don't exist on source (default: false)");
			Environment.Exit(0);
		}
		
		public static void Main(string[] args) {
			Console.WriteLine("PostgreSQL Sync");
			Console.WriteLine("Copyright (C)2009 by Martin Faust (faust@tzi.de)");
			
			string source = null, destination = null;
			SyncMode mode = SyncMode.Incremental;
			bool delete = false;
			
			if (args.Length == 0)
				usage();
			
			for(int i=0; i<args.Length; i++) {
				switch(args[i]) {
				case "--incrementatal": mode = SyncMode.Incremental; break;
				case "--complete": mode = SyncMode.Complete; break;
				case "--source": source = args[i+1]; i++; break;
				case "--destination": destination = args[i+1]; i++; break;
				case "--delete": delete = true; break;
				default:
					usage();
					break;
				}
			}
			if (source == null || destination == null)
				usage();
			
			PSync ps = new PSync(source, destination);
			ps.Delete = delete;
			ps.Mode = mode;
			ps.Start();
			ps.Dispose();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

Share

About the Author

mf040
Architect
Germany Germany
Utilizing my experience of industry-scale real-time graphics programming, design, development of software, as well as European research projects I want to bring in new ideas for creative projects.
Companies:
- 2009-now BTC AG: software for the renewable energy sector.
- 2007-2009 Digital Media: Audio, Graphics and GIS Web Services(http://maps.bremen.de)
- 2001-2007 artecLab://art/work/technology: Mixed Reality, Computer Games and eLearning
- 1998-2001 STN ATLAS Elektronik: real-time graphics for ground warfare simulation
 
For a complete resume see http://e56.de/download/resume.pdf

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 19 Aug 2009
Article Copyright 2009 by mf040
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid