2BrightSparks

Using Filters in SyncBack: Choose Which Files and Folders Are Copied

Most folders contain things you do not need in a backup: temporary files, caches, downloaded installers, build output. Sometimes it is the other way round and you only want one type of file, such as your Word documents or your photos. SyncBack gives you two ways to choose what a profile copies. You can tick and untick folders and files in the selection tree, or you can write filters that match files and folders by name.

Filters are simple once you know how SyncBack matches them, but there is one mistake that catches almost everyone the first time. This article explains how filters work, shows that mistake and how to avoid it, and covers how filters and the selection tree work together.

TL;DR

A profile has two filter lists: Files/folders to copy and Files/folders NOT to copy. Filters are matched against the path relative to the source and destination folders. Folder paths end with a backslash and file paths do not. If you only put *.docx in the copy list, SyncBack will not look inside any sub-folders, so also add *\. Exclude filters win over include filters, and ticks in the selection tree win over both. Use Test Filters (Ctrl+T) to check a filter before you run the profile.

Selections or filters?

The selection tree (the Choose sub-directories and files button on the profile's Simple page) shows the folders and files in your source, and you tick the ones you want. It is the easiest way to pick a handful of specific folders.

Filters are rules. Instead of pointing at particular files, you describe them by name or pattern, for example "every file ending in .tmp" or "every folder called Cache". A filter keeps working as new files and folders appear, which makes filters the better choice when you want to include or exclude a kind of file wherever it is.

Many profiles use both: the tree to choose the main folders, and a few exclude filters to keep out the clutter inside them.

Where to find the filters

Modify your profile and click Change Filter on the Simple page. You can also open the same window from the selection tree, using Change Filter in its menu.

The filter window has a list at the top for Files/folders to copy and a list below it for Files/folders NOT to copy, each with its own Add and Remove buttons. To change an existing filter, double-click it or select it and press F2. You can add several filters in one go by separating them with a forward slash, for example *.tmp/*.bak/*.log.

What a filter is compared with

This is the part that explains almost every filter problem. Unless it starts with a drive letter, a filter is not compared with the full path of a file, such as C:\My Files\Reports\2026.docx. It is compared with the path relative to the profile's source (and destination) folder.

Say your source folder is C:\My Files\ and it contains a folder called Reports with a file in it called 2026.docx, plus a file in the top folder called notes.txt. The filters are compared with:

  • \Reports\
  • \Reports\2026.docx
  • \notes.txt

Three rules follow from this:

  • Every path starts with a backslash.
  • Folder paths end with a backslash. File paths do not. That trailing backslash is how a filter tells a folder from a file.
  • The source and destination folders themselves are not part of the path. This is deliberate: the source and destination are different folders, but their sub-folders have the same names, so a relative filter works on both sides.

Because every path starts with a backslash, SyncBack helps when you add a filter that does not. If you type Reports\*.docx, it is changed to *\Reports\*.docx, which matches .docx files in a folder called Reports at any depth. To mean only the Reports folder directly under the source folder, type \Reports\*.docx. A filter that already starts with *, such as *.tmp, is left as it is.

A filter that starts with a drive letter, such as C:\My Files\Reports\*.docx, is an absolute filter and is compared with the full path instead. Relative filters are usually the better choice, because one relative filter covers both the source and the destination.

The two filter lists

For each file and folder, SyncBack first checks the Files/folders to copy list. If the item does not match anything in that list, it is skipped. If it does match, SyncBack then checks the Files/folders NOT to copy list, and if it matches anything there it is skipped.

In other words, exclude filters win over include filters. The usual setup is to leave * in the copy list, which matches everything, and add the things you do not want to the NOT to copy list. That list is not empty in a new profile: it already skips things that should not be backed up, such as SyncBack's own temporary files, desktop.ini, thumbs.db, the System Volume Information folder and browser caches. Add your own entries to it rather than replacing it.

For example, to also skip temporary files and any folder called Cache, add these to the NOT to copy list:

  • *.tmp
  • *\Cache\

Filters are not case-sensitive, so *.tmp also matches REPORT.TMP.

The common mistake: nothing copied from sub-folders

You want to back up only your Word documents, so you remove * from the copy list and put *.docx there instead. You run the profile, and it only copies the .docx files that are directly in the source folder. Every sub-folder is skipped.

The reason is the trailing backslash. A folder such as \Reports\ does not end in .docx, so it does not match *.docx, so SyncBack skips the folder and never looks inside it. The documents in it are never seen.

The fix is to also add *\ to the copy list. That matches every folder (because every folder path ends with a backslash), so SyncBack goes into all the folders, and *.docx then picks out the Word documents inside them:

  • Files/folders to copy: *\ and *.docx
  • Files/folders NOT to copy: leave as it is

The opposite mistake is putting only *\ in the copy list. That includes every folder but no files at all, because no file path ends with a backslash. If you want all files and folders, use *.

SyncBack tries to catch this for you. If you click OK and nothing in the copy list could match a folder, you see a warning that starts "It looks like your filters are just for files". If you see it, you have almost certainly made this mistake.

This short video shows the mistake and the fix:

Filters are applied from the top down

SyncBack scans the source starting at the top folder and works its way down. When a folder is filtered out, everything inside it is ignored as well, however well the files inside would have matched your filters. This is why the *\ filter matters so much.

It also catches people who try to pick out one deep folder by name. Take this structure:

  • \Parent\
  • \Parent\Child\

If the copy list contains only \Child\*.txt, nothing is copied. \Parent\ does not match the filter, so SyncBack never looks inside it, and in any case the Child folder's path is \Parent\Child\, not \Child\. Every folder on the way down has to be included:

  • \Parent\
  • \Parent\Child\
  • \Parent\Child\*.txt

For a case like this, ticking the folder in the selection tree is usually easier than writing filters.

Example filters

These examples use DOS expressions, the default filter type. * matches any number of characters, including backslashes, and ? matches a single character. Those are the only wildcards: character ranges such as [a-z] are not supported.

To do this List Filters
Copy everything (the usual setting) Copy *
Copy only text files, in all folders Copy *\ and *\*.txt
Copy only text files in folders called temp, wherever they are Copy *\ and *\temp\*.txt
Copy only text files in the temp folder directly under the source folder Copy \temp\ and \temp\*.txt
Skip temporary and backup files NOT to copy *.tmp and *.bak
Skip every folder called Cache, wherever it is NOT to copy *\Cache\
Skip Office lock files (they start with ~$) NOT to copy *\~$*

SyncBack does not accept semi-colons in DOS expression filters.

Testing your filters

Before you run the profile, check your filters with Test Filters in the filter window's menu, or press Ctrl+T. Enter a path and SyncBack tells you whether it would be copied. Two things to remember when you type the path:

  • Enter a folder with a trailing backslash, for example \Reports\. Without it, the name is treated as a file.
  • Enter a relative path such as \Reports\2026.docx, not a full path such as C:\My Files\Reports\2026.docx. A full path only refers to one side of the profile.

Test the folder as well as a file inside it. Test Filters checks one path at a time, so \Reports\2026.docx can show as included while \Reports\ itself is excluded, and then the file is never reached. With only *.docx in the copy list, testing \Reports\ shows it as excluded. Add *\ and the same test shows it as included because of that filter.

If your source, destination or filters contain variables, the test may not be exact, because the value of a variable can change from one run to the next. A simulated run shows what a profile will actually do without copying anything.

Filters and the selection tree

When a file or folder has been ticked or unticked in the selection tree, that decision is used and the filters are not checked for it. The filters are only used for items you have not made a decision about in the tree. So you can exclude all .txt files with a filter and still tick one particular .txt file in the tree, and that one file will be copied. The same goes for folders: a folder you have ticked is scanned even if a filter would exclude it.

When you change the filters and click OK, SyncBack re-applies them to the selections you have already made in the tree. For example, if you add *.tmp to the NOT to copy list and you had ticked a .tmp file in the tree, you are asked whether to untick it.

You can also create a filter from the tree. Right-click a file or folder and choose, for example, Exclude files with this extension or Exclude folders with this name, and the matching filter is added to the list for you. There are matching Include options too.

This video shows the selection tree, including the right-click filter options:

More filter options

Filter types

The Filter menu in the filter window lets you choose the filter type. DOS expressions are the default and are what this article uses. SyncBackSE and SyncBackPro can also use regular expressions, which are more powerful but slower and harder to write (see A Brief Introduction to Regular Expressions). There is also an Old V3 style type, kept for compatibility with very old profiles.

Variables in filters

Filters can contain variables, such as Windows environment variables like %USERPROFILE%. In SyncBackSE and SyncBackPro you can also use your own profile, group or global variables, and one variable can hold several filters separated by forward slashes.

For example, you could create a global variable called CompanyExcludes with the value *.log/\Temp\/*\~*.* and add %CompanyExcludes% to the NOT to copy list of every profile. To change the exclusions for all of those profiles, you edit the one variable. The help file has more examples.

Windows file exclusion filters

Windows keeps its own list of files that should not be included in backups, such as files in the temporary folder. In SyncBackSE and SyncBackPro you can tick Use Windows file exclusion filters in the filter window's Settings menu to skip those files as well as the ones in your own lists. This option is not available with Fast Backup unless the archive attribute is being used.

Filters and speed

Excluding a folder does more than stop its files being copied. SyncBack does not open an excluded folder at all, so a filter such as *\node_modules\ or *\Cache\ also saves the time it would take to scan everything inside it. On folders with many thousands of small files that can make a real difference to the run time.

If a profile does not need filters at all, tick Do not use filters (can improve performance) in the filter window's Settings menu. With large numbers of files this can reduce the run time noticeably. The selection tree has a matching option, Do not use selections (can improve performance).

Filters apply to the destination too

The same filters are used when SyncBack scans the destination. A file or folder that is filtered out is ignored on both sides: it is not copied, and it is not deleted either. So if you run a Mirror profile and later add *.iso to the NOT to copy list, the .iso files already in the destination stay where they are. If you want them gone, delete them yourself.

Removing a filter works the other way. Files that were skipped before become part of the profile, so the next run copies them, and in a Mirror profile any of them that are in the destination but no longer in the source may be deleted. After any filter change, a simulated run shows you exactly what the next run will do.

Filters and restores

A restore uses the profile's filters and selections. Because they use relative paths, that works as expected as long as you restore from and to the profile's normal folders. If you restore from a sub-folder of your backup instead (for example one dated folder, when the destination uses a variable such as %DATE%), the relative paths no longer line up and your filters and selections could skip files you want back. When a profile uses filters or selections, the restore wizard asks whether you want to switch them off. In that case, say yes. See Restoring from a Backup for more on restores.

Which edition do I need?

Include and exclude filters, DOS expressions, Test Filters and creating filters from the selection tree are in all editions, including SyncBackFree. Regular expression filters, your own variables and the Windows file exclusion filters need SyncBackSE or SyncBackPro. See the edition comparison for everything else.

Conclusion

Filters come down to one idea: they are compared with the path relative to the source folder, and folders end with a backslash. Keep * in the copy list and add what you do not want to the NOT to copy list. If you do narrow the copy list to certain files, add *\ so SyncBack still looks inside your folders. Test with Ctrl+T before you rely on a new filter, and check the log after the first run to see what was copied and what was skipped (this video on reading the log shows where to look).

For every option in the filter window, see Filter Settings in the help file.

Noted Customers

Back to top