Clienteling isn’t a new theory. It can be traced back hundreds of years when shopkeepers …
SymmetricDS not only supports the synchronization of database tables, but it also supports the synchronization of files and folders. Using one tool and one interface, users can now synchronize their database and file system. This tutorial will walk through configuring SymmetricDS Pro to sync files.
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.
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.
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.
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.
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.