FreeFileSync
- Folder Comparison and Synchronization -

Usage:

  1. Choose left and right directories.

  2. "Compare" them.

  3. Select synchronization settings.

  4. Press "Synchronize..." to begin synchronization.

Main Dialog:

  1. Start comparison

  2. Specify comparison settings

  3. Set sync configuration

  4. Start synchronization

  5. Add additional folder pairs

  6. Swap sides

  7. Select left and right directories

  8. Save/load configuration

  9. Exclude files

  10. Specify category for display

  11. Synchronization statistics/preview

Menu bar:

Menu "File"

  • 1. Compare
    Start comparing both sides according to comparison settings (compare by filesize and date or by content).

  • 2. Synchronize...
    Begin synchronization and copy files as seen on the middle grid of the main dialog.

  • Switch View
    After comparison has finished the relation between files on left and right side can be visualized by two views:

1. „Comparison Result“ shows a category for each row like „existing on left side only“ or „left file is newer“.

2. „Synchronization Preview“ is the result of the synchronization configuration applied on each category. The effective directions in which the files will be copied are shown.

  • New
    Clears all configuration data and restores an initial state.

  • Save Configuration...
    Save the current settings into a file.

  • Load Configuration...
    Load configuration from file.

  • Quit
    Exit FreeFileSync.

Menu "Advanced"

  • Language
    Change the language of the tool.

  • Global Settings...
    A number of settings that have a global status in the sense that they will be applied to all GUI and batch configurations (*.ffs_gui and *.ffs_batch).

  • Create Batch Job
    Creates a FreeFileSync batch file (*.ffs_batch) that executes a predefined synchronization without user intervention.

  • Export File List...
    Export all data that     is currently shown on the main grids as a *.csv file that can be imported into Excel.

Menu "Help"

  • Content
    Show this helpfile.

  • Check for new version
    Check online whether a more recent version of FreeFileSync is existing.

  • About...
    Credits.


Backup strategies

1. Full backup with versioning of old files

In synchronization settings select and specify a "User-defined directory" for deletion handling. FreeFileSync will place files that have been deleted or overwritten with newer versions into corresponding time-stamped sub directories. This provides a space-optimized way to retain all older versions of files while the most recent ones are available in main source and target directories.

2. Full backup to different target directories

All directory input fields may contain environment variables and special macros that are expanded during synchronization. This allows for complete backups into different target directories.

Example:

A directory "C:\Source" requires a daily backup into a time-stamped target directory like "C:\Target_2009-10-08". Base directories are set up accordingly:

Source folder: "C:\Source"
Target folder: "C:\Target_%date%"

Latter will be interactively replaced with the current date during synchronization. In order to further automate this process, you can create a *.ffs_batch file with this configuration and choose "ignore errors" to avoid the warning that target directory is not (yet) existing.


Batch Scripting (Windows)

In order to facilitate using FreeFileSync and RealtimeSync in advanced synchronization scenarios, creating batch files is a good way to provide additional functionality. The following section will give some general hints and examples for custom *.cmd and *.bat files.

  • When starting a batch file from RealtimeSync make synchronous calls to FreeFileSync only. This will prevent RealtimeSync continue detecting changes while synchronization is still in progress.

  • During execution of a Windows Batch file (*.bat/*.cmd) a black console window is shown. You can hide it using the Visual Basic script "RunSilent.vbs" located in FreeFileSync's installation directory.

    Usage:

wscript C:\Program files\FreeFileSync\Invisible.vbs C:\MyBatchFile.cmd

  • FreeFileSync returns with an Errorlevel below zero if unresolved problems remain:

"C:\Program Files\FreeFileSync\FreeFileSync.exe" "H:\Silent_Config.ffs_batch"
if not errorlevel 0 (
  ::if something went wrong, add special treatment here
  echo Errors occurred during synchronization...
  pause
)

Example: Shutdown PC after synchronization

::start FreeFileSync Batch Job
"C:\Users\ZenJu\Desktop\SyncJob.ffs_batch"
  ::schedule shutdown after 10 seconds
shutdown /s /t 10

Example: A simple locking facility – (Note: FreeFileSync already has a more powerful directory locking mechanism implemented that allows multiple writers in parallel)

:tryAgain
if not exist \\share\folder\lock (
  ::create the lock
  echo This is a lock file > \\share\folder\lock
  ::execute the synchronization batch job synchronously
  "C:\Program Files\FreeFileSync\FreeFileSync.exe" "C:\MySyncJob.ffs_batch"
  del \\share\folder\lock
) else (
  ::wait 5 seconds then try starting sync again:
  choice /C:AB /T:5 /D:A > NUL
  goto tryAgain
)


Compare by file size

Sometimes you might want to compare both sides by file size only, ignoring last modification timestamps.

Instructions:

Open file "GlobalSettings.xml" located either in "%appdata%\FreeFileSync" or the installation folder and change the value of XML node <FileTimeTolerance> to some sufficiently large number of seconds, for example 2.000.000.000. Changed files will now be detected as a conflict (same date, different file size) and the default synchronization direction for conflicts can be used.


Comparison Settings

I. Compare by "File time and size"

This variant evaluates two equally named files as being equal when they have the same modification time and file size. When the comparison is started, the following decision tree is processed:

  1. file exists on one side only

      • left only

      • right only

  2. file exists on both sides

    1. different date

      • left newer

      • right newer

    2. same date

      • equal

      • conflict (same date, different size)

This results into the following categories:

  • left only

  • right only

  • left newer

  • right newer

  • equal

  • conflict (same date, different size)

II. Compare by "File content"

Two files which have the same name are marked as equal if and only if they have the same content. This option is more useful for consistency checks rather than backup operations for reasons of speed. The file modification time is not taken into account at all.

  1. file exists on one side only

      • left only

      • right only

  2. file exists on both sides

      • equal

      • different content

As a result the files are separated into the following categories:

  • left only

  • right only

  • equal

  • different content

Symbolic link handling

FreeFileSync offers three options to configure processing of symbolic links (also called symlinks or soft links):

  1. Exclude: skips symbolic links while scanning input directories.

  2. Direct: configures synchronization of the symbolic link object itself and not its target. symbolic links will be visible on main grid as a separate entity with corresponding meta data. Links pointing to directories are not traversed and the link object is copied directly during synchronization.

  3. Follow: dereferences symbolic links, i.e. they are treated like their target objects. Links pointing to directories are traversed like ordinary folders and the target of each link is copied during synchronization.

Note:

  • In Windows the options described above always apply to "Reparse Points". Reparse Points are a more general concept including for example symbolic links, junctions and mount points. The term "symbolic link" has been retained nevertheless for harmonization with Linux.

  • Copying symbolic links requires the application to be started with administrator rights.


Daylight saving time (Windows)

A common problem synchronization software has to deal with are +-1 hour file time shifts after a Daylight Saving Time (DST) switch has occurred. This can be observed for example when a FAT-formatted volume is compared against an NTFS volume as frequently happening with USB memory sticks. Files that previously appeared to be in sync are now shown with an one hour modification time offset, although they have not been modified by the user or by other means.

The reason for this strange behavior lies in the way NTFS and FAT drives store file times: NTFS stores time in UTC format, while FAT uses local time.

When times stored in these two different formats are compared, one format has to be converted into the other first. In both cases Windows uses the current DST status as well as current time zone information for its calculations. Consequently the result of this comparison is dependent from current system settings and in particular file times that used to be the same can show up as different after a DST switch.

For a detailed discussion about this issue refer to: http://www.codeproject.com/KB/datetime/dstbugs.aspx

Solution:

Luckily FreeFileSync users need not to worry about this issue. Each file on a FAT volume automatically gets additional meta data encoded in its creation date that enables a correct file time calculation. This not only solves all DST issues but also time shifts that occur due to travel between different time zones.

Note:

  • In order for FreeFileSync to start handling DST and timezone differences, an initial full synchronization is required. Subsequent syncs will never show a time difference again.

  • If a FAT volume is scanned the first time by FreeFileSync this will take longer than usual since additional meta data is written for each file.


Send error notification via email

  1. Create a FreeFileSync batch file using "Run minimized".

  2. Set error handling to "Exit instantly" or "Ignore errors" to avoid having a pop-up stop the program flow. In case errors occur FreeFileSync will exit with a return code < 0 that can be checked via the ERRORLEVEL batch command.

  3. Create a *.cmd or *.bat file to specify the location of FreeFileSync.exe and pass the name of the ffs_batch file as first argument; e.g.:

"C:\Program Files\FreeFileSync\FreeFileSync.exe" "C:\SyncJob.ffs_batch"
@if not errorlevel 0 (
    echo An error occured!
    pause
)

Instead of displaying "An error occurred!" you can specify another command like sending an email notification (using a third party tool).


Exclude files

Excluding files and directories works by specifying a phrase that is compared against a file or directory path. Only if the file or directory matches at least one entry in the include list and none of the entries in the exclude list it passes filtering. The phrase is also a file or directory name, but it must be relative to the base sync-directory and may additionally include wild cards like '*' or '?'.

Example: Exclude all sub directories

Include: *
Exclude: *\

This will exclude all objects within the two directories that end with a '\' character, which is interpreted as the end of a directory name.

Example: Mirror-sync from C:\Source to D:\Target

Exclude single file C:\Source\file.txt:
 Filter: \file.txt

Exclude single folder C:\Source\sample\subfolder:
 Filter: \sample\subfolder\

Exclude all *.tmp files located in subfolder only:
 Filter: \sample\subfolder\*.tmp

Exclude files (and folders) named thumbs.db in all sub directories:
 Filter: *\thumbs.db

Exclude all files and folders that have test as part of their name:
 Filter: *test*

Exclude multiple entries; separate by semicolon or newlines:
 Filter: *.tmp; *.doc; *.bak

Note:
A filter phrase „\fileOrDir” matches both a file or a directory named „fileOrDir”. In most cases there is no need to distinguish between a phrase to be used for files or directories. In cases where it is clear you want to process directories only, you can give a hint by adding a backslash: „\fileOrDir\”. Now this filter will be matched against directories only.

Note:
In most cases manually specifying a filter phrase is not necessary! You can exclude files, directories and even complete lists of both directly on main grid via context menu.


External applications

By default FreeFileSync opens the operating system's standard file browser on each double-click by invoking "explorer /select, "%name"" on Windows and "xdg-open "%dir"" on Linux.

However the user is free to integrate other external applications into FreeFileSync: navigate to "Menu -> Advanced -> Global settings: External Applications" and add or replace a command string. The first entry is used when double-clicking a row while all other entries are only available via right-click context menu on main dialog. The following macros are available:

%name   - full file or directory name
%dir    - directory part only
%nameCo - Other side's counterpart to %name
%dirCo  - Other side's counterpart to %dir

Examples:

  • Start visual difference tool:
    "C:\Program Files\WinMerge\WinMergeU.exe" "%name" "%nameCo"

  • Show file in Windows Explorer:
    explorer /select, "%name"

  • Open file in associated application:
    cmd /c start "" "%name" or simply "%name"

  • Open console dialog:
    cmd /k cd /D "%dir"

Note:
Don't forget to use quotation marks if file names contain spaces!


Key Features

  1. Detection of moved and renamed files

  2. Copy locked files using Windows Volume Shadow Copy Service. (Windows only)

  3. Support for multiple folder pairs with distinct configuration

  4. Compare files (bytewise or by date) and synchronize them.

  5. Create Batch Jobs for automated synchronization with or without GUI.

  6. Optimized performance, coded in C++ completely.

  7. Native 32 and 64 bit builds

  8. Transactional file copy

  9. Synchronization database for propagation of deleted files and conflict detection

  10. Cross-Platform

  11. Full support for Windows/Linux Symbolic Links and Windows Junction Points.

  12. Full unicode support.

  13. Full network support.

  14. Built-in support for very long filenames (more than MAX_PATH = 260 characters).

  15. Copy NTFS alternate data streams, compressed and encrypted file attributes

  16. Lean & easily accessible UI: only useful functionality, no feature bloat.

  17. Support for filesizes larger than 4 GB.

  18. Option to move files to Recycle Bin instead of deleting/overwriting them.

  19. Ignore directories "\RECYCLER" and "\System Volume Information" with default filter. (Windows only)

  20. Delete before copy: Avoid disc space shortages for large sync-jobs.

  21. Filter functionality to include/exclude files from synchronization.

  22. Automatically handle daylight saving time changes on FAT/FAT32 volumes.

  23. Portable version available (selectable via installer).

  24. Opt-in for automatic online update.

  25. Localized versions are available for many languages.

  26. Create recurring backups with macros %time%, %date% within directory names

  27. Copy file create/modification times when synchronizing.

  28. Advanced locking strategy to allow multiple synchronization processes (e.g. multiple writers, same network share).

  29. Case-sensitive synchronization of file, directory and symlink names


Macros

All directory names may contain macros that are expanded during synchronization. Begin and end of each macro is marked by a '%' character. Besides special macros handling time and date, the operating system's environment variables can also be used.

Internal macros:

%time%    - current time, format [hhmmss], e. g. "201340"
%date%    - current date, e. g. "2010-07-13"

%weekday% - day of the week, e. g. "Monday"
%week%    - calendar week, e. g. "28"

%day%     - current day, e. g. "21"
%month%   - current month, e. g. "July"
%year%    - current year, e. g. "2010"

%hour%    - current hour, e. g. "20"
%min%     - current minute, e. g. "13"
%sec%     - current second, e. g. "40"

Environment variables: (Windows)

%AllUsersProfile%   e. g. C:\ProgramData
%AppData%           e. g. C:\Users\username\AppData\Roaming
%LocalAppData%      e. g. C:\Users\username\AppData\Local
%ProgramData%       e. g. C:\ProgramData
%ProgramFiles%      e. g. C:\Program Files
%ProgramFiles(x86)% e. g. C:\Program Files (x86)
%Public%            e. g. C:\Users\Public
%UserProfile%       e. g. C:\Users\username
%WinDir%            e. g. C:\Windows
%Temp%              e. g. C:\Windows\Temp

Special folder locations (Windows)

%csidl_Desktop%     e. g. C:\Users\username\Desktop
%csidl_MyMusic%     e. g. C:\Users\username\My Documents\My Music
%csidl_Pictures%    e. g. C:\Users\username\My Documents\My Pictures
%csidl_MyVideo%     e. g. C:\Users\username\My Documents\My Videos
%csidl_MyDocuments% e. g. C:\Users\username\My Documents
%csidl_StartMenu%   e. g. C:\Users\username\Start Menu
%csidl_Favorites%   e. g. C:\Users\username\Favorites
%csidl_Templates%   e. g. C:\Users\username\Templates
%csidl_Resources%   e. g. C:\Windows\Resources

Note: Each macro listed here also has a variant to address public folders. E.g. csidl_MyMusic → csidl_PublicMusic

Example:

  • C:\Backup\%username%_Config expands to
    C:\Backup\ZenJu_Config

  • %appdata%\FreeFileSync      expands to
    C:\Documents and Settings\ZenJu\Application Data\FreeFileSync

Hint:

You can add a great amount of flexibility to Batch Synchronization (*.ffs_batch) by creating new temporary environment variables in a *.bat/*.cmd file that are evaluated by FreeFileSync at runtime!

Example:

The batch configuration file C:\SyncJob.ffs_batch contains macro %MyVar% instead of an absolute target directory and is invoked by a *.cmd file:

set MyVar=C:\Target
cd "C:\Program files\FreeFileSync"
FreeFileSync.exe C:\SyncJob.ffs_batch (->%MyVar% is replaced by C:\Target during execution)

    Note:
    Temporary environment variables created with the "set" command are only valid if the batch job is started by calling the executable directly! Using "start /wait" or relying on Shell Execute creates a new program context without these temporal variables.


Schedule a Batch Job

  1. Create a new batch job via FreeFileSync's main dialog:
    Menu->Advanced->Create batch job and save it, for example, as "C:\SyncJob.ffs_batch".

  2. If the batch job shall run without user interaction or as part of a batch script, make sure that no popup dialog stops the progress: Disable checkbox "Show progress dialog" to avoid blocking while showing the result after synchronization. Alternatively you can select the "On completion" action "Close progress dialog" located in synchronization settings. Note that even if the progress is not shown initially it can be displayed interactively at any time during synchronization, by double-clicking the corresponding systray icon.

  3. In order to prevent error or warning popup messages from stopping progress, set "Error handling" to either "Ignore errors" or "Exit instantly".

  4. Setup your operating system's scheduler

    1. Windows 7 Task Scheduler:

      • Go to Start and enter "taskschd.msc"

      • Create a new basic task and follow the wizard.

      • Make "Program/script" point to the location of FreeFileSync.exe and specify the ffs_batch file under "Add arguments".

      • Use quotes if any paths contain spaces, e.g.: "C:\some folder\SyncJob.ffs_batch"

    2. Windows XP Scheduled Tasks:

      • Go to Start → Control Panel → Scheduled Tasks and select "Add Scheduled Task".

      • Follow the wizard and select FreeFileSync.exe as program to run.

      • Make sure "Run:" is specified as: <FreeFileSync installation directory>\FreeFileSync.exe <ffs_batch file>

    3. Ubuntu Linux Gnome-schedule:

      • Install Gnome-schedule, if necessary: sudo apt-get install gnome-schedule

      • Go to System -> Preferences -> Scheduled tasks

      • Specify the command as: <FreeFileSync installation directory>\FreeFileSync <ffs_batch file>

Note:
Beginning with Windows Vista, the command always needs to start with the path to "FreeFileSync.exe" even if file associations are set! Else the task will return with error code 0xC1, "%1 is not a valid Win32 application".


Synchronize with FTP/WebDAV (Windows)

FreeFileSync does not support accessing FTP volumes directly. But this functionality can be integrated by mapping the FTP web space to a drive letter:

Example: Use the free utility NetDrive (http://www.netdrive.net)

  • Add a "New Site" and specify site name, site URL, drive letter, account and password.

  • Use the newly created drive as if it were a regular hard disk.

Note:
Most FTP drives set a file's time stamp to the current time when synchronizing ignoring the source file's time and date. As a workaround you can do a "compare by filesize"; see corresponding section.

Synchronize with SFTP (Linux)

An SFTP share can be easily mapped onto a local folder for use with FreeFileSync:

  • Install:
    sudo apt-get install sshfs

  • Mount SFTP share:
    sshfs ssh-account@ssh-server:<path> mountpoint

  • Unmount:
    fusermount -u mountpoint


Variable drive letters

USB sticks often get different volume names assigned when plugged into different computers. FreeFileSync offers two solutions to handle this issue:

Option 1: Specify a directory via volume name: Syntax: [<volume name>]\<path>

Use "[ZenJu-USB]\directory" instead of "E:\directory" where "ZenJu-USB" is the name of the USB stick.

It is not required to look up and enter the volume name manually. Just select the corresponding entry in the drop down menu.

Option 2: Use a relative directory name:

  • Use "\directory" instead of "E:\directory"

  • Save and copy synchronization settings to the USB stick: "E:\settings.ffs_gui"

  • Start FreeFileSync by double-clicking on "E:\settings.ffs_gui"
    → Working directory is automatically set to "    E:\" by the operating system so that "\directory" will be resolved as "E:\directory" during synchronization.


Volume Shadow Copy Service (Windows only)

FreeFileSync supports copying locked or shared files by creating a Volume Shadow Copy of the source drive. To enable this feature go to Menu -> Advanced -> Global settings: Copy locked files.

    Note:

  • This functionality is applied to locked files only. Regular files will not use Volume Shadow Copy Service when being synchronized.

  • Creating Volume Snapshots using VSS requires the application to be started with administrator rights.

Troubleshooting

If you experience problems using the Volume Shadow Copy Service a renewal of registration might help. Create and execute a *.cmd batch file with the follow content or enter directly via command line:

cd /d %windir%\system32
Net stop vss
Net stop swprv
regsvr32 ole32.dll
regsvr32 oleaut32.dll
regsvr32 vss_ps.dll
Vssvc /register
regsvr32 /i swprv.dll
regsvr32 /i eventcls.dll
regsvr32 es.dll
regsvr32 stdprov.dll
regsvr32 vssui.dll
regsvr32 msxml.dll
regsvr32 msxml3.dll
regsvr32 msxml4.dll

(Reference: http://support.microsoft.com/kb/940032)


RealtimeSync
- Automated Synchronization -

RealtimeSync's primary function is to trigger synchronization immediately after files in a source directory have changed. However its implementation is more flexible to cover an even broader range of use: A list of directories provided by the user is monitored for changes. Whenever a file within these directories or sub directories is modified OR the directory becomes available (e. g. insert of a USB-stick), RealtimeSync responds by executing the user-specified command line.

Example: Real time synchronization - in combination with FreeFileSync

First start up RealtimeSync.exe located in FreeFileSync's installation directory. Then specify all directories that shall be monitored. Instead of doing this manually you can simply import a *.ffs_batch file via Menu -> File -> Load configuration. This not only extracts all directories relevant for synchronization but also sets up the command-line to execute the *.ffs_batch file each time changes are detected. Now press "Start" to begin monitoring.

    Note:

  • The command-line should not block the progress. If a FreeFileSync batch file is called make sure it is running "minimized" and "error handling” is set to "ignore errors" or "exit instantly".

  • The settings dialog can be skipped by passing a RealtimeSync configuration file (*.ffs_real) OR a FreeFileSync batch file (*.ffs_batch) as first command-line argument to RealtimeSync.exe. This allows for integration with the operating system's auto start facility:
    "C:\Program Files\FreeFileSync\RealtimeSync.exe" "C:\MyConfig.ffs_real"
     "C:\Program Files\FreeFileSync\RealtimeSync.exe" "C:\SyncJob.ffs_batch"

  • Using RealtimeSync is not restricted to starting FreeFileSync. It can also be used in other scenarios, like sending an email whenever a certain directory is modified.

  • If you schedule a Windows batch file (.bat, .cmd), see notes in Batch Scripting.

Example: Automatic synchronization when USB stick is inserted

Save the relevant configuration on the USB stick's root directory to have it called when the stick is mounted. Then configure RealtimeSync as shown in the following:

Whenever directory "H:\Data" becomes available, the command line executes and starts the batch job on the stick. Additionally it also starts the batch job each time files are modified in "H:\Data".

    Note:
    The n ame of the last changed file is written to an environment variable named "changed_file".

Example: Show names of changed files or directories. (Windows)

      Show which file or directory has triggered a change. Enter into command line:
          cmd /c echo "%changed_file%" & pause

      Write a list of all changes to a logfile:
          cmd /c echo "%changed_file%" >> c:\log.txt

Limitations:

  • If multiple changes happen at the same time, only the name of the first file is written to variable "changed_file".

  • While RealtimeSync is executing the command line, monitoring is inactive and changes occurring during this time are lost.


Run as Service (Windows only)

The following step-by-step guide describes how to setup RealtimeSync (or any other application) as a Windows Service. This can be useful if the tool shall run on a SYSTEM account without necessarily requiring a user to log in.

1. Get access to the command-line tools "instsrv.exe" and "srvany.exe" which come with the Windows Server 2003 Resource Kit Tools:

Download: http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

2. Create and register a new Service via command line:

    instsrv <ServiceName> <PathToResourceKit>\srvany.exe

3. Link the new Service with RealtimeSync:

  • Open the Registry editor (Regedit.exe) and navigate to key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<ServiceName>"

  • Add a new key "Parameters".

  • Add a new String value named "Application" and specify a command line that shall be executed as value.

The new service is now ready for operation!

Attention:
When running RealtimeSync as a service the application has no means to interact with the user. Therefore any popup dialog will stop the process flow! Consider the following options when setting up a FreeFileSync batch job:

  • Enable checkbox "Run minimized" to prevent showing the results dialog after synchronization.

  • Set "Error handling" to either "Exit instantly" or "Ignore errors".

You can start the service now via command line or Windows Service administration:

    net start <ServiceName>

Note:
By default the service is created with start-up type "automatic" which runs it on Windows start. This behavior can be changed in Windows Service administration.

If the Service shall be removed from the system, enter via command line:

    instsrv <ServiceName> remove

(Reference: http://support.microsoft.com/kb/137890)


Links

Homepage:
 http://freefilesync.sourceforge.net

FreeFileSync on SourceForge:
http://sourceforge.net/projects/freefilesync

For feedback, suggestions or bug-reports you can write an email to:
zhnmju123 [at] gmx [dot] de

Or report directly to:
http://sourceforge.net/tracker/?group_id=234430

Support the FreeFileSync project:
Paypal