5 1 0:Exclude with Regular Expressions

From SEPsesam


Welcome to the latest SEP sesam documentation version 5.1.0 Apollon. For previous documentation version(s), check documentation archive.


Overview


In a backup task you not only specify the source for your backup but also define any files or patterns you want to exclude from the backup process. Excluding items from backup helps reduce backup storage requirements, and enables you to eliminate unnecessary or redundant files and directories from backup.

You can use regular expressions to define patterns for excluding files or directories. When configuring a backup task in the GUI, you can use options Regular expression or Regular expression with directory support and then specify the items you want to exclude in the field Exclude List. If your list exceeds 1024 characters or if you plan to reuse it, you have the option to create a separate text file with the exclusions. This also allows you to edit and manage the list using any text editor.

Note that on Linux, exclusions can only be specified using regular expressions (regex exclude). However, on Windows, you have the additional option File Pattern to exclude with file patterns.

For more details and instructions, see Creating Exclude List.


Tip
The exclude list on the SEP sesam Linux Client can also be used as an include list by specifying the + (plus) sign at the beginning of a pattern. For details, see Advanced Backup and Restore Options.

Excluding items with regular expressions

With regular expressions you can define patterns for excluding items based on their names or paths. The most common operators used in regular expressions include:

. (dot)
Matches any single character except newline.
* (asterisk)
Matches the preceding element zero or more times.
$ (dollar sign)
Matches the end of the input string.
| (vertical bar or pipe)
Acts as an OR operator, matching either the expression before or after it.
[ ] (square brackets)
Defines a character class, matching any one of the characters enclosed within the brackets.
( ) (parentheses)
Used for grouping and capturing matched text, which enables applying operators to the entire group or allows parts to be referenced or extracted separately.

Note that regular expressions are case-sensitive by default, which means that "A" and "a" are treated as distinct characters.

Note
In 5.1.0.14 Apollon V2, for SEP sesam Linux SBC, the GNU findutils were replaced by Perl-compatible Regular Expressions (PCRE), which are already used on Windows. The key difference in syntax between GNU findutils and PCRE is how metacharacters are handled. In GNU findutils, certain characters like parentheses () and alternation operator | need to be escaped with a backslash, whereas in PCRE, these characters are used directly. For example:
  • GNU findutils default regular expression:

\./sapmnt/\([A-Z][0-9][0-9]\|[A-Z][A-Z][A-Z]\|[A-Z][A-Z][0-9]\)/global/.*BDCLG$

  • PCRE extended regular expression:

\./sapmnt/([A-Z][0-9][0-9]|[A-Z][A-Z][A-Z]|[A-Z][A-Z][0-9])/global/.*BDCLG$

On Windows, SBC already uses Perl-compatible Regular Expressions (PCRE).

Examples

Below are some examples illustrating how regular expressions can be used to exclude items from your backups. For more RegExp examples, see RegExp: Examples for Excluding Matched Patterns.

  • Backing up /var without /var/tmp but including /var/tmp1:
 \./var/tmp$
  • Backing up /var without any file or directory containing the term "tmp":
 /tmp
  • Backing up /usr while avoiding certain file types and specific file names:
 \.o$, \.tmp$, /a\.out$, /old.*\.c$, /old.*$
This regular expression excludes:
  • files with extensions ".o" and ".tmp"
  • files named "a.out"
  • files starting with "old" and ending with ".c"
  • any file or directory starting with "old"


  • Backing up /usr without /usr/var/spool and /usr/var/log:
 \./usr/var/spool$, \./usr/var/log$
  • Avoid all syslog####.log files and directories:
 /syslog[0-9]*.log$
This regular expression excludes files and directories with names that match the pattern "syslog####.log", where #### represents any sequence of digits.


See also

Creating Exclude List - Examples for Excluding Matched Patterns - Exclude with File Patterns - Advanced Backup and Restore Options

Copyright © SEP AG 1999-2024. All rights reserved.
Any form of reproduction of the contents or parts of this manual is allowed only with the express written permission from SEP AG. When compiling and designing user documentation SEP AG uses great diligence and attempts to deliver accurate and correct information. However, SEP AG cannot issue a guarantee for the contents of this manual.