Overview

We will start with a simple configuration for syncing text files from a server node to a client node. The configuration should look familiar if you are already using SymmetricDS for database synchronization. We will introduce a few new configuration pages. Then we'll put our configuration to work by inserting some files to test our synchronization. The final Advanced section will cover some additional features of file sync that you can try.

This tutorial skips the initial installation steps. In this example we have installed SymmetricDS Pro on Windows. During the installation process we choose the Standard 2 Tier Configuration.

Configuration

The first step to configuring file sync is to determine the base folder location. This is the base folder on the file system that we want to synchronize. In our example we will use "C:\filesync\source".

In the SymmetricDS Pro console go to the Configure tab and then select File Triggers. Click the New button.

Give the file trigger a name of "sync_txt". Insert a base directory. Select the Recurse option so sub-folders will also be synchronized. Set the Include Files field to "*.txt", to only synchronize text files. Click Save.

Once the file trigger has been created, we need to link the file trigger to a router. File triggers can be linked to the same routers used to synchronize database data. This means we can use any of the already present database router types. For this example we will keep it simple and use the default SERVER_2_CLIENT router created as part of the Standard 2 Tier Configuration. Any default router from server to client would also work.

Select the new file trigger we just created and click the Link button. Check the SERVER_2_CLIENT router only. Fill in the Target Base Directory with the base directory you would like all of the text files to arrive on the target. If this field is left blank, the base directory on the target will be the same as the source. For this example we chose a target directory of "C:\filesync\target". Click Save.

Testing

The configuration is now complete. It's time to test our scenario. On the source node file system, navigate to the source base directory we initially set. In this example we used "c:\filesync\source". Create two new files named "test.txt" and "test.log". We should only see "test.txt" be synchronized because it matches the pattern "*.txt".

We can now look in the SymmetricDS console for the "test.txt" file to be detected and sent. Go to the Manage->Outgoing Batches screen. Change the channel to "filesync" in the filter area. Also make sure all of the status types are selected. After a few minutes, an outgoing batch should be displayed similar to the following image.

Once the outgoing batch status is marked OK, we can check the target file system for the file. We should only see the "test.txt" file. The "test.log" file does not satisfy the filesync configuration pattern.

Advanced

Now that you have a simple file sync configuration in place, you can test the more advanced features. Try linking the file trigger to a column match router instead of the default router. By using the Detection Expression of "RELATIVE_DIR = :NODE_ID" you can conditionally route files to nodes by the relative directory. This works because RELATIVE_DIR is a column in the table sym_file_snapshot. Now you can place folders in your source base directory with the name of the node you want to route the file to. File sync is not only limited to text files. By clearing the file trigger Include Files field, all files will be synchronized.

Summary

File Sync extends the power and flexibility of SymmetricDS. Users continue to surprise us with new creative uses for file sync. Feel free to share your experience with file sync with us in the comment section.

Austin Brougher

Austin is a software developer who focuses on integration services for SymmetricDS. With a background in Java and C++, he has extensive experience with embedded systems, data center controls, and network protocols. In his spare time, he likes tinkering with iOS devices, and using microcontrollers to control board games and garage doors.