duplicati/duplicati · error · UserInformationException

FiltersCannotBeUsedOnCommandLineAndInParameterFile

FiltersCannotBeUsedOnCommandLineAndInParameterFile

Error message

Filters cannot be specified on the commandline if filters are also present in the parameter file. Use the special --{0}, --{1}, or --{2} options to specify filters inside the parameter file. Each filter must be prefixed with either a + or a -, and multiple filters must be joined with {3}.

What it means

Thrown by the Duplicati CLI when the user specifies both command-line filters (--include/--exclude) and a --parameters-file that itself contains filters. Duplicati disallows this because merging command-line filters with file-based filters produces ambiguous ordering, leading to incorrect backup selection. The message directs the user to use --replace-filter, --append-filter, or --prepend-filter inside the parameter file instead, with filters prefixed by + or - and joined by the OS path separator.

Source

Thrown at Duplicati/CommandLine/CLI/Program.cs:379

                        prependfilter = value;
                        return false;
                    }
                    else if (key.Equals("replace-filter", StringComparison.OrdinalIgnoreCase))
                    {
                        replacefilter = value;
                        return false;
                    }

                    return true;
                });

                var opt = tmpparsed.Item1;
                var newfilter = tmpparsed.Item2;

                // If the user specifies parameters-file, all filters must be in the file.
                // Allowing to specify some filters on the command line could result in wrong filter ordering
                if (!filter.Empty && !newfilter.Empty)
                    throw new Duplicati.Library.Interface.UserInformationException(Strings.Program.FiltersCannotBeUsedWithFileError2, "FiltersCannotBeUsedOnCommandLineAndInParameterFile");

                if (!newfilter.Empty)
                    filter = newfilter;

                if (!string.IsNullOrWhiteSpace(prependfilter))
                    filter = Library.Utility.FilterExpression.Combine(Library.Utility.FilterExpression.Deserialize(prependfilter.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries)), filter);

                if (!string.IsNullOrWhiteSpace(appendfilter))
                    filter = Library.Utility.FilterExpression.Combine(filter, Library.Utility.FilterExpression.Deserialize(appendfilter.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries)));

                if (!string.IsNullOrWhiteSpace(replacefilter))
                    filter = Library.Utility.FilterExpression.Deserialize(replacefilter.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries));

                foreach (KeyValuePair<String, String> keyvalue in opt)
                    options[keyvalue.Key] = keyvalue.Value;

                var command = cargs.Count >= 1 ? cargs[0] : string.Empty;
                var isBackup = command.Equals("backup", StringComparison.OrdinalIgnoreCase);

View on GitHub (pinned to 3f348be3e3)

Solutions

  1. Remove all --include/--exclude options from the command line and put all filters in the parameters file.
  2. Use --replace-filter, --append-filter, or --prepend-filter on the command line to control how file-based filters are modified.
  3. Each filter value must be prefixed with + (include) or - (exclude); join multiple filters with the OS path separator (: on Linux/macOS, ; on Windows).

Example fix

// before
duplicati-cli backup s3://bucket /data --include=*.txt --parameters-file=config.txt
// (config.txt also has filter entries)

// after — consolidate all filters in the parameters file:
duplicati-cli backup s3://bucket /data --parameters-file=config.txt
// Or override from command line using the special options:
duplicati-cli backup s3://bucket /data --parameters-file=config.txt --replace-filter="+*.txt"
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking Duplicati CLI with a parameters file, check for conflicting filters:
bool hasCommandLineFilters = args.Any(a => a.StartsWith("--include") || a.StartsWith("--exclude"));
bool hasParametersFile = args.Any(a => a.StartsWith("--parameters-file"));
if (hasCommandLineFilters && hasParametersFile)
    throw new InvalidOperationException("Cannot use --include/--exclude with --parameters-file. Use --replace-filter/--append-filter/--prepend-filter instead.");

Prevention

When it happens

Trigger: Invoking the Duplicati CLI with both `--include=*.txt` (or similar filter options) on the command line AND `--parameters-file=config.txt` where the file also contains filter entries. The check `!filter.Empty && !newfilter.Empty` fires when both sources have non-empty filter lists.

Common situations: User migrates from command-line-only operation to a parameters file but leaves old --include/--exclude flags in the command line. Or a shared parameters file already has filters and the user adds ad-hoc ones on the command line.

Related errors


AI-assisted analysis of duplicati/duplicati@3f348be3e3 (2026-08-13). Data as JSON: /api/errors/a4deee350ec92f02. Report an issue: GitHub.