From e7b97ebb7915b2f86c85a2d10fa162aa326cd39e Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Sun, 27 Dec 2015 22:30:43 +0100 Subject: [PATCH] Improved documentation for filter usage inside scripts --- Duplicati/CommandLine/Help.cs | 1 + Duplicati/CommandLine/help.txt | 2 +- .../Modules/Builtin/run-script-example.bat | 15 +++++++++++++++ .../Library/Modules/Builtin/run-script-example.sh | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Duplicati/CommandLine/Help.cs b/Duplicati/CommandLine/Help.cs index 77ad3dab6..4c89801c4 100644 --- a/Duplicati/CommandLine/Help.cs +++ b/Duplicati/CommandLine/Help.cs @@ -92,6 +92,7 @@ namespace Duplicati.CommandLine tp = tp.Replace("%BACKENDS%", string.Join(", ", Library.DynamicLoader.BackendLoader.Keys)); tp = tp.Replace("%MONO%", Library.Utility.Utility.IsMono ? "mono " : ""); tp = tp.Replace("%APP_PATH%", System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location)); + tp = tp.Replace("%PATH_SEPARATOR%", System.IO.Path.PathSeparator.ToString()); tp = tp.Replace("%EXAMPLE_SOURCE_PATH%", Library.Utility.Utility.IsClientLinux ? "/source" : "D:\\source"); tp = tp.Replace("%EXAMPLE_SOURCE_FILE%", Library.Utility.Utility.IsClientLinux ? "/source/myfile.txt" : "D:\\source\\file.txt"); tp = tp.Replace("%EXAMPLE_RESTORE_PATH%", Library.Utility.Utility.IsClientLinux ? "/restore" : "D:\\restore"); diff --git a/Duplicati/CommandLine/help.txt b/Duplicati/CommandLine/help.txt index 393d61925..bced10bba 100644 --- a/Duplicati/CommandLine/help.txt +++ b/Duplicati/CommandLine/help.txt @@ -375,7 +375,7 @@ Duplicati can apply globbing and regex filter rules to backup and restore specif Regex: [.*test\.txt] Inside scripts and the commandline --parameters-file, where multiple filters are supplied with a single option, filters must be prefixed with either a plus (+) or a (-), for include and exclude respectively. Example: - +*.txt;-[.*\.xyz];+* + +*.txt%PATH_SEPARATOR%-[.*\.xyz]%PATH_SEPARATOR%+* # ============================================================================= diff --git a/Duplicati/Library/Modules/Builtin/run-script-example.bat b/Duplicati/Library/Modules/Builtin/run-script-example.bat index 1d6ace271..93f24709d 100644 --- a/Duplicati/Library/Modules/Builtin/run-script-example.bat +++ b/Duplicati/Library/Modules/Builtin/run-script-example.bat @@ -54,6 +54,21 @@ REM will be ignored: REM echo "Hello! -- test, this line is ignored" REM echo "--new-option=""This will be a setting""" +REM Filters are supplied in the DUPLICAT__FILTER variable. +REM The variable contains all filters supplied with --include and --exclude, +REM combined into a single string, separated with semicolon (;). +REM Filters set with --include will be prefixed with a plus (+), +REM and filters set with --exclude will be prefixed with a minus (-). +REM +REM Example: +REM --include=*.txt --exclude=[.*\.abc] --include=* +REM +REM Will be encoded as: +REM DUPLICATI__FILTER=+*.txt;-[.*\.abc];+* +REM +REM You can set the filters by writing --filter= to stdout. +REM You may want to append to the existing filter like this: +REM echo "--filter=+*.123;%DUPLICATI__FILTER%;-*.xyz" REM ############################################################################### diff --git a/Duplicati/Library/Modules/Builtin/run-script-example.sh b/Duplicati/Library/Modules/Builtin/run-script-example.sh index 6dc1818be..6ab7c51f3 100644 --- a/Duplicati/Library/Modules/Builtin/run-script-example.sh +++ b/Duplicati/Library/Modules/Builtin/run-script-example.sh @@ -54,6 +54,21 @@ # echo "Hello! -- test, this line is ignored" # echo "--new-option=\"This will be a setting\"" +# Filters are supplied in the DUPLICAT__FILTER variable. +# The variable contains all filters supplied with --include and --exclude, +# combined into a single string, separated with colon (:). +# Filters set with --include will be prefixed with a plus (+), +# and filters set with --exclude will be prefixed with a minus (-). +# +# Example: +# --include=*.txt --exclude=[.*\.abc] --include=* +# +# Will be encoded as: +# DUPLICATI__FILTER=+*.txt:-[.*\.abc]:+* +# +# You can set the filters by writing --filter= to stdout. +# You may want to append to the existing filter like this: +# echo "--filter=+*.123:%DUPLICATI__FILTER%:-*.xyz" ###############################################################################