Child pages
  • Incremental backup Windows PC
Skip to end of metadata
Go to start of metadata


Backup is performed with the means of FreeFileSync software that is operated from within the batch file. Batch file contains all parameters needed for the backup operation.  It can backup to a network or local location. Current procedure accomplishes incremental backup with a retention period indicated in configuration file.

Setup generates reports that being sent over email as attachments in case of backup operation completed with errors. Otherwise, if no errors registered, "OK" email is sent. In addition there is CSV file in public location that can help to get overview of backup situation (this is experimental feature yet)


We suppose that destination backup folder (Samba share) is created and credentials are known.

The following files are required for setup:

  • backup.bat - This is batch job that contains all backup parameters and backup procedures. The header part of the file should be edited manually for each host. The file is attached to this page. Also can be found in Appendix 1
  • SwithMail.exe - Toll for sending emails. Used for sending reports. The file is attached to this page. Also can be downloaded from
  • BatchRun.ffs_batch - FreeFileSync general profile. Normally doesn't change from host to host. The file is attached to this page. Also it can be found in Appendix 1
  • backup-on-idle.xml - This file can be imported to the Windows Task Scheduler (instead of scheduling backup job manually)
  • FreeFileSync installation file - Latest version can be downloaded from

On host machine:

      0. In case of installation on Windows 10 machine that will communicate to Linux Samba share: check if you can login to the destination backup folder with Samba credentials using File Explorer. In some cases Windows OS cannot see Samba share if it is running outdated protocol and in some other cases that not yet explored enough (displayed error: "Windows cannot access \\IP_ADDRESS. Check the spelling of the name... etc.)". Solution: Run command prompt with administrator rights and execute two following commands. Then reboot and try again.

sc.exe config lanmanworkstation depend= bowser/mrxsmb10/nsi 
sc.exe config mrxsmb20 start= disabled
  1. Install FreeFileSync to default folder C:\Program Files\FreeFileSync
  2. Create new folder C:\backup_config
  3. Copy to this folder following files:
    1. backup.bat
    2. SwithMail.exe
    3. BatchRun.ffs_batch
  4. Open in a text editor backup.bat file and edit parameters in top part of the file:
    • Destination folder (ex. \\\FAMC-GREEN)
    • Network username
    • Network password
    • Name of FreeFileSync profile (keep default one BatchRun.ffs_batch)
    • Retention period, days
    • Global report file location (keep default one "\\\TH Share\_backup_global_report\backup_global_report.csv")
    • Indicate one or multiple folders to be backed up (ex. C:\Users\FAMC\Desktop)
    • Gmail user that will send reports
    • Gmail password
    • Send email to address
  5. Open Task Scheduler (press Win+R combination and run taskschd.msc)
  6. Import the file backup-on-idle.xml to create new task
  7. Test setup by running the task on demand (right click and run). Check  folders C:\backup_config\batch_logs and C:\backup_config\ffs_logs and read reports.
    • Note that first run might be reported with errors because destination folders are not existed. However destination folders will be created automatically after the first run.

Appendix 1

:: Created by Daniel
:: Install FreeFileSync in default C:\Program Files\FreeFileSync folder
:: Create folder C:\backup_config and copy sample configuration files to it
:: Configure parameters below


:: Path to the destination backup folder either network or local.
:: In case of a network place use format \\SERVER\Folder in case of a local foler use DRIVE_LETTER:\FOLDER
:: Don't put backslash at the end of the line
SET Destination=\\\FAMC-GREEN

:: Server credentials - in case of network location.
:: If using local folder or public share that doesn't require credentials, keep both fields blank.
SET User=famcbackup
SET Password=htHL678kh

:: Path to FFS profile file
SET FFSProfile=BatchRun.ffs_batch

:: Changed and deleted files retention period
SET retention=30

:: Global report file located in public network location
SET GlobalReportFile="\\\TH Share\_backup_global_report\backup_global_report.csv"

:: Set folders for backup. Spaces are allowed. No need quote marks. Every location must start with drive letter, colon, backslash (C:\... D:\...).
:: Keep empty or delete lines that are not needed. If needed more location, add more lines using the same format.
SET source[1]=C:\Users\FAMC\Desktop
SET source[2]=
SET source[3]=
SET source[4]=
SET source[5]=
SET source[6]=
SET source[7]=
SET source[8]=
SET source[9]=
SET source[10]=

:: Send email report as:
SET GmailPassword="auroville 2018 AV"

:::::::::::::: DON'T EDIT BELOW THIS LINE ::::::::::::::

:: Creating TIMESTAMP in good format
FOR /f "tokens=2 delims==" %%a IN ('wmic OS Get localdatetime /value') DO SET "dt=%%a"
SET "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
SET "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
SET "timestamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"

:: Checking if backup was running today already. If yes - go to END (do nothing)
IF EXIST batch_logs\batch_log_%YYYY%-%MM%-%DD%* GOTO END

:: Creating batch log file
IF NOT EXIST "batch_logs" MKDIR "batch_logs"
SET BatchLogFile=batch_logs\batch_log_%timestamp%.txt
ECHO This is backup log created on %timestamp% > %BatchLogFile%

:: Creating FFS log file
IF NOT EXIST "ffs_logs" MKDIR "ffs_logs"
SET FFSLogFile=ffs_logs\ffs_log_%timestamp%.txt
ECHO. > %FFSLogFile%

:: Preparing message for user
ECHO Dear user! > message.txt
ECHO. >> message.txt
ECHO We backup only following folders on this computer >> message.txt
ECHO. >> message.txt

:: Mounting network volume or skipping this if no need to login
IF "%User%"=="" GOTO NOLOGIN
net use %Destination% /user:%User% %Password%
		ECHO ERROR Mounting network volume %Destination% >> %BatchLogFile%
	) ELSE (
		ECHO OK Mounting network volume %Destination% >> %BatchLogFile%


:: Running cycles that will sync pairs of directories using same FFS profile for each pair separately
SET i=1
SET ErrLevel=0

	SETLOCAL EnableDelayedExpansion
	:: Defining Source and Target folders for current cycle run
	IF "!source[%i%]!"=="" GOTO ENDLOOP
	SET Source=!source[%i%]!
	SET Target=!source[%i%]:~0,1!!source[%i%]:~2,150!
	:: Running backup for current couple
	"C:\Program Files\FreeFileSync\FreeFileSync.exe" %FFSProfile% -dirpair "%Source%" "%Destination%\%Target%"
			ECHO ERROR %Source% %Destination%\%Target% >> %BatchLogFile%
			SET /A ErrLevel+=1
		) ELSE (ECHO OK %Source% %Destination%\%Target% >> %BatchLogFile%)
	:: Identifying name of FFS log file that was just created
	SETLOCAL EnableExtensions DisableDelayedExpansion
	SET "LastLog="
	FOR /f "delims=" %%a IN ('DIR /b /o-d ffs_logs\ 2^>NUL') DO (
	IF NOT DEFINED LastLog SET "LastLog=%%a"
	:: Streaming last FFS report into common report file
	TYPE "ffs_logs\%LastLog%" >> %FFSLogFile%
	DEL "ffs_logs\%LastLog%"
	:: Adding source folder to user message that will be displayed at the end
	ECHO %Source% >> message.txt
	SET /A i+=1	

:: Deleting files older than %retention% from backup _modified folder
PUSHD "%Destination%\_modified" &&(
    forfiles -s -m *.* -d -%retention% -c "cmd /c del /s /q @path"
	) & POPD
	ECHO WARNING Deleting files older than %retention% days from %Destination%\_modified. Nothing to delete >> %BatchLogFile%		
	) ELSE (ECHO OK Deleted files older than %retention% days from %Destination%\_modified. >> %BatchLogFile%)

:: Deleting log file older than %retention% from batch_logs and ffs_logs

forfiles /p "batch_logs" /s /m *.* /d -%retention% /c "cmd /c del @path"
	ECHO WARNING Deleting batch log files older than %retention% days. Nothing to delete >> %BatchLogFile%		
	) ELSE (ECHO OK Deleted batch log files older than %retention% days. >> %BatchLogFile%)
forfiles /p "ffs_logs" /s /m *.* /d -%retention% /c "cmd /c del @path"
	ECHO WARNING Deleting FFS log files older than %retention% days. Nothing to delete >> %BatchLogFile%		
	) ELSE (ECHO OK Deleted FFS log files older than %retention% days. >> %BatchLogFile%)
:: Checking for errors

:: Sending email Backup completed successful
SwithMail.exe /s /from %GmailUser% /name "backup" /pass %GmailPassword% /server "" /p "587" /SSL /to %SendEmailTo% /sub "%COMPUTERNAME% backup OK" /b "Backup completed successful"


:: Sending email Backup completed with ERROR with %FFSLogFile% %BatchLogFile% in attachment
SwithMail.exe /s /from %GmailUser% /name "backup" /pass %GmailPassword% /server "" /p "587" /SSL /to %SendEmailTo% /sub "%COMPUTERNAME% backup ERROR" /b "Backup completed with errors. See log attached." /a "%FFSLogFile%|%BatchLogFile%"


::Writing to global report CSV file (experimental)
ECHO %YYYY%-%MM%-%DD%,%HH%:%Min%:%Sec%,%COMPUTERNAME%,%ErrLevel% >> %GlobalReportFile%

IF "%User%"=="" GOTO NOLOGOUT	
:: Restartning 	Workstation service to release network share
net stop lanmanworkstation /y
net start lanmanworkstation /y


::Displaing message to user
ECHO. >> message.txt
ECHO If you want to add more backup locations, please talk to Admin >> message.txt
msg * < message.txt

<?xml version="1.0" encoding="utf-8"?>
<FreeFileSync XmlType="BATCH" XmlFormat="11">
        <VersioningFolder Style="TimeStamp">%Destination%\_modified\%Target%</VersioningFolder>
            <Item>\System Volume Information\</Item>
        <TimeSpan Type="None">0</TimeSpan>
        <SizeMin Unit="None">0</SizeMin>
        <SizeMax Unit="None">0</SizeMax>
    <Errors Ignore="true" Retry="0" Delay="5"/>
    <PostSyncCommand Condition="Completion"/>
        <ProgressDialog Minimized="true" AutoClose="true"/>
        <LogfileFolder Limit="-1">C:\backup_config\ffs_logs</LogfileFolder>

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="">
    <Principal id="Author">
  <Actions Context="Author">