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. Setup comparison settings

  3. Setup synchronization settings

  4. Start synchronization

  5. Tree overview panel

  6. Add additional folder pairs

  7. Select left and right folders

  8. Synchronization preview

  9. Save/load configuration

  10. Filter files

  11. Select categories for preview

  12. Synchronization statistics


Backup Strategies

1. Full backup with versioning of old files

In synchronization settings select "Versioning" for deletion handling. FreeFileSync will move files that have been deleted or overwritten with newer versions into the provided directory and append a time-stamp. This is effectively a space-optimized way to save all older versions of files separately while the 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 dynamically 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 popup message that target directory is not (yet) existing.


Batch Scripting

FreeFileSync can be called from command line and supports integration into batch scripts. This section gives some general hints and examples for Windows *.cmd and *.bat scripts.

When FreeFileSync is started in batch mode (a *.ffs_batch file is passed as argument) it returns one of the following status codes:

    Return Codes
    0 - Synchronization completed successfully
    1 - Synchronization completed with warnings
    2 - Synchronization completed with errors
    3 - Synchronization was aborted

Now you can check if synchronization was successful from a script:

"C:\Program Files\FreeFileSync\FreeFileSync.exe" "H:\some folder\SyncJob.ffs_batch"
if errorlevel 1 (
  ::if return code is 1 or greater, something went wrong, add special treatment here
  echo Errors occurred during synchronization...
  pause
)

Instead of displaying "An error occurred!" you can also send an email notification (using a third party tool).

Attention
Make sure your script is not blocked by a popup dialog. Consider the following options when setting up a FreeFileSync batch job:

  • Disable checkbox "Show progress dialog" or have "On completion" automatically close the results dialog after synchronization.

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


Compare by file size only

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 considers two files with the same name as equal when modification time and file size match. The following cases are distinguished:

  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 with 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 since it is naturally slower. 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 handling of symbolic links (also called symlinks or soft links):

  1. Exclude: Skip symbolic links while scanning directories.

  2. Direct: Evaluate the symbolic link object directly. Symbolic links will be shown as a separate entity on grid. Links pointing to directories are not traversed and the link object is copied directly during synchronization.

  3. Follow: Treat symbolic links like the object they are pointing to. Links pointing to directories are traversed like ordinary directories and the target of each link is copied during synchronization.

    Note

  • Under Windows the symbolic link options apply to all symbolic links, "volume mount points" and "NTFS junction points".

  • Copying symbolic links requires 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.


Exclude items

Files and directories are only considered for synchronization if they pass the filter. They have to match at least one entry in the include list and none of the entries in the exclude list:

  1. Each list item must be a file or directory path relative to synchronization base directories

  2. Multiple items must be separated by ';' or a new line

  3. Wild cards like '*' or '?' may be used

Example: Exclude items for mirror-sync from C:\Source to D:\Target

Single file C:\Source\file.txt:
 Exclude: \file.txt

Single folder C:\Source\subfolder:
 Exclude: \subfolder\

All files (and folders) named thumbs.db:
 Exclude: *\thumbs.db

All *.tmp files located in subfolder only:
 Exclude: \subfolder\*.tmp

Files and folders containing temp somewhere in their path:
 Exclude: *temp*

Multiple entries separated by semicolon:
 Exclude: *.tmp; *.doc; *.bak

Example: Exclude all files and folders located in subdirectories of base directories

Exclude: *\*

Example: Include only files and folders located in subdirectories of base directories

Include: *\*

    Note

  • For simple exclusions just right-click and exclude one or a list of items directly on main grid via context menu.

  • A filter string is compared against both file and directory paths. If you want to consider directories only, you can give a hint by appending a path separator: "dirname\".


External applications

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

However you are 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 executed when double-clicking a row on main grid while all other entries are only available via right-click context menu. The following internal macros may be used:

%item_path%     - full file or folder name
%item_folder%   - folder part only
%item2_path%    - Other side's counterpart to %item_path%
%item2_folder%  - Other side's counterpart to %item_folder%

Examples:

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

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

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

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

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


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"

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

%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
%ComputerName%      e. g. Zenju-PC
%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
%Temp%              e. g. C:\Windows\Temp
%UserName%          e. g. Zenju
%UserProfile%       e. g. C:\Users\<username>
%WinDir%            e. g. C:\Windows

Special folder locations (Windows)

%csidl_Desktop%     e. g. C:\Users\<username>\Desktop
%csidl_Favorites%   e. g. C:\Users\<username>\Favorites
%csidl_MyDocuments% e. g. C:\Users\<username>\Documents
%csidl_MyMusic%     e. g. C:\Users\<username>\Music
%csidl_MyPictures%  e. g. C:\Users\<username>\Pictures
%csidl_MyVideos%    e. g. C:\Users\<username>\Videos
%csidl_Nethood%     e. g. C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Network Shortcuts
%csidl_Programs%    e. g. C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
%csidl_Resources%   e. g. C:\Windows\Resources
%csidl_StartMenu%   e. g. C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu
%csidl_Startup%     e. g. C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\StartUp
%csidl_Templates%   e. g. C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Templates

Note: Most macros listed here also have a variant for 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 FreeFileSync batch file C:\SyncJob.ffs_batch contains macro %MyVar% instead of an absolute target folder and is invoked by a *.cmd file:

set MyVar=C:\Target
"C:\Program files\FreeFileSync\FreeFileSync.exe" C:\SyncJob.ffs_batch
::%MyVar% is resolved as C:\Target during synchronization

    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

  2. If the batch job shall run without user interaction or as part of an unattended 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: Even if the progress dialog is not shown at the beginning, a user can make it visible during synchronization by double-clicking the FreeFileSync systray icon.

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

  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"

    Note
    Beginning with Windows Vista the "Program/script" always needs to be a path to "FreeFileSync.exe" even if ffs_batch file associations are set!     Else the task will return with error code 0xC1, "%1 is not a valid Win32 application" if a ffs_batch file is entered directly.

    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.

      • Enter "Run:" as: <FreeFileSync installation directory>\FreeFileSync.exe <job name>.ffs_batch

    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 <job name>.ffs_batch


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]\folder" instead of "G:\folder" where "ZENJU-USB" is the name of the USB stick that is currently mounted in volume G:\.

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 "\folder" instead of "G:\folder"

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

  • Start FreeFileSync by double-clicking on "G:\settings.ffs_gui"
    → Working directory is automatically set to "    G:\" by the operating system so that "\folder" will be resolved as "G:\folder" 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 is a small tool which executes a command line each time it detects changes in one of the monitored directories or a directory becomes available (e. g. insert of a USB-stick). Usually this command line will simply trigger a FreeFileSync batch job.

Example: Real time synchronization - in combination with FreeFileSync

Start RealtimeSync.exe located in FreeFileSync's installation directory. Then specify all folders that shall be monitored. Instead of doing this manually you can import a *.ffs_batch file via Menu -> Program -> Open. 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 should not block progress. Make sure the FreeFileSync batch job does not show any popup dialogs. See notes in Batch Scripting.

  • 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 can be integrated into 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.

Example: Automatic synchronization when USB stick is inserted

Save a ffs_batch configuration into the USB stick's root directory and 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 full path of the last changed file and the action that triggered the change notification (create, update or delete) are written to the environment variables "change_path" and "change_action".

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

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

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

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

    wscript "C:\Program files\FreeFileSync\HideConsole.vbs" C:\MyBatchFile.cmd

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)

RealtimeSync is designed as a background process which does not need further attention once it is running. Depending on your requirements there are a number of ways to start it together with the operating system. Generally the goal is to execute a command line like the following: <installation folder>\RealtimeSync.exe <path to *.ffs_real or *.ffs_batch file>

Example:

    "C:\Program Files\FreeFileSync\RealtimeSync.exe" "C:\some folder\SyncJob.ffs_batch"

  1. RealtimeSync should be monitoring only while a specific user is logged in: Create a new shortcut, enter the command line from above as target and place it into the user's autostart folder.

  2. RealtimeSync should be monitoring while Windows is online irrespective of currently logged in users: Create a new task in your operating systems's task scheduler and have it execute the command line above when the system starts. See Schedule a Batch Job for an example how to add a new task. Then change the user to run the task to "SYSTEM" - a special user account always running in the background.


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:
zenju [at] gmx [dot] de

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

Support the FreeFileSync project:
Donate via PayPal