Menu

Home

Welcome to SlimSync wiki!

SlimSync is a java library for simple repository synchronization. It was made primarily for designers who need in their programs synchronize different repositories. SlimSync can work with virtually any type of resource repository. At the moment it supports local file systems, WebDAV. It can be easily extended to other types by implementing given interface.

Current implementation limitations (plans for future extension):

  • Only one-way synchronization, i.e. from source to target, not both directions (mirroring)
  • Uses only MD5 hash to compare files, should also use modification date and more than one signature (e.g. SHA1)
  • Only two types of repositories, should be implemented support for FTP, SFTP, and SCP

This library can be easily wrapped into a command line tool.

Why another synchronization tool?

  • This is a library, i.e. primarily developed to be used inside other programs.
  • There is no other so lightweight and simple library. Some other libraries are over-sophisticated (for massive bulks of files, online synchronization, etc. ) making them difficult to use and cumbersome to incorporate them as a library into another software.

Example 1 - local file system

Example how to perform one-way synchronization between repositories both on local file system.

/**

 * Synchronize two local file system repositories
 * @param sourceFolder
 * @param destinationFolder
 */
public void runExample(String sourceFolder, String destinationFolder) {

    // create repository managers
    RepositoryManager srcManager = new LocalFileManager(sourceFolder);
    RepositoryManager dstManager = new LocalFileManager(destinationFolder);

    // scan repositories
    Node srcRoot = srcManager.scan(true);
    Node dstRoot = dstManager.scan(true);

    // perform one-way synchronization
    if(Synchronizer.syncOneWay(srcRoot, srcManager, dstRoot, dstManager) == false) {
        logger.info("Error while synchronizing folders: \"" + sourceFolder + "\" -> \"" + destinationFolder + "\"");
    } else {
        logger.info("Successfully synchronized folders: \"" + sourceFolder + "\" -> \"" + destinationFolder + "\"");
    }
}

Example 2 - local folder to WebDav

Example how to perform one-way synchronization from local folder to remote WebDav repository. WebDav folder is specified as URI (e.g. "https://myserver.com/test/").

/**

 * Synchronize local folder to remote WebDav folder
 * @param sourceFolder
 * @param destinationFolder
 */
public void runExample(String sourceFolder, String destinationFolderUri, String username, String password) {

    // create repository managers
    RepositoryManager srcManager = new LocalFileManager(sourceFolder);
    RepositoryManager dstManager = new WebDavManager(username, password, URI.create(destinationFolderUri));

    // scan repositories
    Node srcRoot = srcManager.scan(true);
    Node dstRoot = dstManager.scan(true);

    // perform one-way synchronization
    if(Synchronizer.syncOneWay(srcRoot, srcManager, dstRoot, dstManager) == false) {
        logger.info("Error while synchronizing folders: \"" + sourceFolder + "\" -> \"" + destinationFolderUri + "\"");
    } else {
        logger.info("Successfully synchronized folders: \"" + sourceFolder + "\" -> \"" + destinationFolderUri + "\"");
    }
}

Maven dependency

Add to yours POM file this dependency:

<dependency>
    <groupId>net.sourceforge.slimsync</groupId>
    <artifactId>slimsync</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

Because SlimSync is so far released as SNAPSHOT, you need to also specify this repository in yours project POM file:

<repositories>
    <repository>
        <id>nexus.oss.snapshot</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        <name>OSS Snapshot repositories</name>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

Project Members:


MongoDB Logo MongoDB