RegExp: Examples for Excluding Matched Patterns

From SEPsesam
Other languages:

Copyright © SEP AG 1999-2022. 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.

Docs latest icon.png Welcome to the latest SEP sesam documentation version 4.4.3/5.0.0 Jaglion. For previous documentation version(s), check Documentation archive.


Use-case scenario

In all of the following examples, we assume that the directory to be backed up contains the following subdirectories and files:

# find /backupsource/
./ADirectory1
./ADirectory1/file1
./dir-exclude
./dir-exclude/one
./DIRECTORY12FALL
./DIRECTORY12FALL/file1
./ADirectory2
./ADirectory2/file1
./BDirectory2
./BDirectory2/file1
./BDirectory1
./BDirectory1/file1
./BDirectory1/file2
./1235-Directory1
./1235-Directory1/file1

The backup source in each example is /backupsource/. The excludes are entered manually into the exclude list field (but they can also be used in an exclude file). For more information, see Creating Exclude List.

Information sign.png Note
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.

RegExp exclude Beefalo V2.jpg

The backup job is started with extended logging level (-v 2) so that the excluded files are visible in the log.

RegExp exclude options Beefalo V2.jpg

Examples

All files and directories starting with the letter "A" are to be ignored

"/backupsource/A.*"

Result from the log:

2019-06-30 15:27:30: sbc-3008: Info:     Processing item: [./backupsource/]...
2019-06-30 15:27:30: sbc-3108: Info:     Item processed successfully: [./backupsource/]
2019-06-30 15:27:30: sbc-3014: Info:     Item [./backupsource/ADirectory1] excluded.
2019-06-30 15:27:30: sbc-3014: Info:     Item [./backupsource/ADirectory1/file1] excluded.
2019-06-30 15:27:30: sbc-3008: Info:     Processing item: [./backupsource/dir-exclude]...
2019-06-30 15:27:30: sbc-3108: Info:     Item processed successfully: [./backupsource/dir-exclude]
2019-06-30 15:27:30: sbc-3008: Info:     Processing item: [./backupsource/dir-exclude/one]...
2019-06-30 15:27:30: sbc-3108: Info:     Item processed successfully: [./backupsource/dir-exclude/one]
2019-06-30 15:27:30: sbc-3008: Info:     Processing item: [./backupsource/VERZEICHNIS12FALL]...
2019-06-30 15:27:30: sbc-3108: Info:     Item processed successfully: [./backupsource/DIRECTORY12FALL]
2019-06-30 15:27:30: sbc-3008: Info:     Processing item: [./backupsource/DIRECTORY12FALL/file1]...
2019-06-30 15:27:30: sbc-3108: Info:     Item processed successfully: [./backupsource/DIRECTORY12FALL/file1]
2019-06-30 15:27:30: sbc-3014: Info:     Item [./backupsource/ADirectory2] excluded.
2019-06-30 15:27:30: sbc-3014: Info:     Item [./backupsource/ADirectory/file1] excluded.
2019-06-30 15:27:30: sbc-3008: Info:     Processing item: [./backupsource/BDirectory2]...
2019-06-30 15:27:30: sbc-3108: Info:     Item processed successfully: [./backupsource/BDirectory2]
2019-06-30 15:27:30: sbc-3008: Info:     Processing item: [./backupsource/BDirectory2/file1]...

All files and directories ending with "1" are to be ignored

"/backupsource/.*1$"

Result from the log:

2019-06-30 15:37:50: sbc-3014: Info:     Item [./backupsource/ADirectory1] excluded.
2019-06-30 15:37:50: sbc-3014: Info:     Item [./backupsource/ADirectory1/file1] excluded.
2019-06-30 15:37:50: sbc-3008: Info:     Processing item: [./backupsource/dir-exclude]...
2019-06-30 15:37:50: sbc-3108: Info:     Item processed successfully: [./backupsource/dir-exclude]
2019-06-30 15:37:50: sbc-3014: Info:     Item [./backupsource/BDirectory2/datei1] excluded.
2019-06-30 15:37:50: sbc-3014: Info:     Item [./backupsource/BDirectory1] excluded.
2019-06-30 15:37:50: sbc-3014: Info:     Item [./backupsource/BDirectory1/datei1] excluded.
2019-06-30 15:37:50: sbc-3008: Info:     Processing item: [./backupsource/BDirectory1/file2]...
2019-06-30 15:37:50: sbc-3108: Info:     Item processed successfully: [./backupsource/BDirectory1/file2]
2019-06-30 15:37:50: sbc-3014: Info:     Item [./backupsource/1235-Directory1] excluded.
2019-06-30 15:37:50: sbc-3014: Info:     Item [./backupsource/1235-Directory1/file1] excluded.

All files and directories ending with an arbitrary number are to be ignored

"/backupsource/.*\d$"

Result from the log:

2019-06-30 15:49:45: sbc-3108: Info:     Item processed successfully: [./backupsource/dir-exclude/one]
2019-06-30 15:49:45: sbc-3008: Info:     Processing item: [./backupsource/DIRECTORY12FALL]...
2019-06-30 15:49:45: sbc-3108: Info:     Item processed successfully: [./backupsource/DIRECTORY12FALL]
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/DIRECTORY12FALL/file1] excluded.
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/ADirectory2] excluded.
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/ADirectory2/file1] excluded.
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/BDirectory2] excluded.
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/BDirectory2/file1] excluded.
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/BDirectory1] excluded.
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/BDirectory1/file1] excluded.
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/BDirectory1/file2] excluded.
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/1235-Directory1] excluded.
2019-06-30 15:49:45: sbc-3014: Info:     Item [./backupsource/1235-Directory1/file1] excluded.
2019-06-30 15:49:45: sbc-3500: Info:     All hardlinks completely saved.

All files and directories containing a two digit number are to be ignored

"/backupsource/DIRECTORY(\d\d)FALL"

Result from the log:

2019-06-30 15:54:28: sbc-3008: Info:     Processing item: [./backupsource/dir-exclude]...
2019-06-30 15:54:28: sbc-3108: Info:     Item processed successfully: [./backupsource/dir-exclude]
2019-06-30 15:54:28: sbc-3008: Info:     Processing item: [./backupsource/dir-exclude/one]...
2019-06-30 15:54:28: sbc-3108: Info:     Item processed successfully: [./backupsource/dir-exclude/one]
2019-06-30 15:54:28: sbc-3014: Info:     Item [./backupsource/DIRECTORY12FALL] excluded.
2019-06-30 15:54:28: sbc-3014: Info:     Item [./backupsource/DIRECTORY12FALL/one1] excluded.
2019-06-30 15:54:28: sbc-3008: Info:     Processing item: [./backupsource/ADirectory2]...
2019-06-30 15:54:28: sbc-3108: Info:     Item processed successfully: [./backupsource/ADirectory2]
2019-06-30 15:54:28: sbc-3008: Info:     Processing item: [./backupsource/ADirectory2/one1]...

All files and directories ending with the string "-exclude" are to be ignored

"/backupsource/.*-exclude"

Results from the log:

2019-06-30 15:32:49: sbc-3008: Info:     Processing item: [./backupsource/ADirectory1/datei1]...
2019-06-30 15:32:49: sbc-3108: Info:     Item processed successfully: [./backupsource/ADirectory1/datei1]
2019-06-30 15:32:49: sbc-3014: Info:     Item [./backupsource/dir-exclude] excluded.
2019-06-30 15:32:49: sbc-3014: Info:     Item [./backupsource/dir-exclude/eins] excluded.
2019-06-30 15:32:49: sbc-3008: Info:     Processing item: [./backupsource/DIRECTORY12FALL]...
2019-06-30 15:32:49: sbc-3108: Info:     Item processed successfully: [./backupsource/DIRECTORY12FALL]

All files and directories that only contain lower case letters are to be ignored

"/backupsource/[a-z]"
2019-06-30 15:56:48: sbc-3008: Info:     Processing item: [./backupsource/ADirectory1/file1]...
2019-06-30 15:56:48: sbc-3108: Info:     Item processed successfully: [./backupsource/ADirectory1/file1]
2019-06-30 15:56:48: sbc-3014: Info:     Item [./backupsource/dir-exclude] excluded.
2019-06-30 15:56:48: sbc-3014: Info:     Item [./backupsource/dir-exclude/one] excluded.
2019-06-30 15:56:48: sbc-3008: Info:     Processing item: [./backupsource/DIRECTORY12FALL]...
2019-06-30 15:56:48: sbc-3108: Info:     Item processed successfully: [./backupsource/DIRECTORY12FALL]

All files and directories that contain upper case letters and a two digit number are to be ignored

"/backupsource/[A-Z]+\d\d[A-Z]+"
2019-06-30 16:02:23: sbc-3108: Info:     Item processed successfully: [./backupsource/ADirectory1/file1]
2019-06-30 16:02:23: sbc-3008: Info:     Processing item: [./backupsource/dir-exclude]...
2019-06-30 16:02:23: sbc-3108: Info:     Item processed successfully: [./backupsource/dir-exclude]
2019-06-30 16:02:23: sbc-3008: Info:     Processing item: [./backupsource/dir-exclude/one]...
2019-06-30 16:02:23: sbc-3108: Info:     Item processed successfully: [./backupsource/dir-exclude/one]
2019-06-30 16:02:23: sbc-3014: Info:     Item [./backupsource/DIRECTORY12FALL] excluded.
2019-06-30 16:02:23: sbc-3014: Info:     Item [./backupsource/DIRECTORY12FALL/file1] excluded.
2019-06-30 16:02:23: sbc-3008: Info:     Processing item: [./backupsource/ADirectory2]...
2019-06-30 16:02:23: sbc-3108: Info:     Item processed successfully: [./backupsource/ADirectory2]
2019-06-30 16:02:23: sbc-3008: Info:     Processing item: [./backupsource/ADirectory2/file1]...
2019-06-30 16:02:23: sbc-3108: Info:     Item processed successfully: [./backupsource/ADirectory2/file1]
2019-06-30 16:02:23: sbc-3008: Info:     Processing item: [./backupsource/BDirectory2]..

See also

Creating Exclude ListExclude with Regular Expressions