{"record":{"id":"a4deee350ec92f02","repo":"duplicati/duplicati","slug":"filterscannotbeusedoncommandlineandinparameterfile","errorCode":"FiltersCannotBeUsedOnCommandLineAndInParameterFile","errorMessage":"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}.","messagePattern":"Filters cannot be specified on the commandline if filters are also present in the parameter file\\. Use the special --(.+?), --(.+?), or --(.+?) 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 (.+?)\\.","errorType":"exception","errorClass":"UserInformationException","httpStatus":null,"severity":"error","filePath":"Duplicati/CommandLine/CLI/Program.cs","lineNumber":379,"sourceCode":"                        prependfilter = value;\r\n                        return false;\r\n                    }\r\n                    else if (key.Equals(\"replace-filter\", StringComparison.OrdinalIgnoreCase))\r\n                    {\r\n                        replacefilter = value;\r\n                        return false;\r\n                    }\r\n\r\n                    return true;\r\n                });\r\n\r\n                var opt = tmpparsed.Item1;\r\n                var newfilter = tmpparsed.Item2;\r\n\r\n                // If the user specifies parameters-file, all filters must be in the file.\r\n                // Allowing to specify some filters on the command line could result in wrong filter ordering\r\n                if (!filter.Empty && !newfilter.Empty)\r\n                    throw new Duplicati.Library.Interface.UserInformationException(Strings.Program.FiltersCannotBeUsedWithFileError2, \"FiltersCannotBeUsedOnCommandLineAndInParameterFile\");\r\n\r\n                if (!newfilter.Empty)\r\n                    filter = newfilter;\r\n\r\n                if (!string.IsNullOrWhiteSpace(prependfilter))\r\n                    filter = Library.Utility.FilterExpression.Combine(Library.Utility.FilterExpression.Deserialize(prependfilter.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries)), filter);\r\n\r\n                if (!string.IsNullOrWhiteSpace(appendfilter))\r\n                    filter = Library.Utility.FilterExpression.Combine(filter, Library.Utility.FilterExpression.Deserialize(appendfilter.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries)));\r\n\r\n                if (!string.IsNullOrWhiteSpace(replacefilter))\r\n                    filter = Library.Utility.FilterExpression.Deserialize(replacefilter.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries));\r\n\r\n                foreach (KeyValuePair<String, String> keyvalue in opt)\r\n                    options[keyvalue.Key] = keyvalue.Value;\r\n\r\n                var command = cargs.Count >= 1 ? cargs[0] : string.Empty;\r\n                var isBackup = command.Equals(\"backup\", StringComparison.OrdinalIgnoreCase);\r","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/duplicati/duplicati/blob/3f348be3e33f5d72d414e3ad55839c2ba34dda67/Duplicati/CommandLine/CLI/Program.cs#L361-L397","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove all --include/--exclude options from the command line and put all filters in the parameters file.","Use --replace-filter, --append-filter, or --prepend-filter on the command line to control how file-based filters are modified.","Each filter value must be prefixed with + (include) or - (exclude); join multiple filters with the OS path separator (: on Linux/macOS, ; on Windows)."],"exampleFix":"// before\nduplicati-cli backup s3://bucket /data --include=*.txt --parameters-file=config.txt\n// (config.txt also has filter entries)\n\n// after — consolidate all filters in the parameters file:\nduplicati-cli backup s3://bucket /data --parameters-file=config.txt\n// Or override from command line using the special options:\nduplicati-cli backup s3://bucket /data --parameters-file=config.txt --replace-filter=\"+*.txt\"","handlingStrategy":"validation","validationCode":"// Before invoking Duplicati CLI with a parameters file, check for conflicting filters:\nbool hasCommandLineFilters = args.Any(a => a.StartsWith(\"--include\") || a.StartsWith(\"--exclude\"));\nbool hasParametersFile = args.Any(a => a.StartsWith(\"--parameters-file\"));\nif (hasCommandLineFilters && hasParametersFile)\n    throw new InvalidOperationException(\"Cannot use --include/--exclude with --parameters-file. Use --replace-filter/--append-filter/--prepend-filter instead.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Consolidate all filters into the parameters file when using one.","Use --replace-filter, --append-filter, or --prepend-filter to modify file-based filters from the command line.","Filter values in the special options must be prefixed with + (include) or - (exclude) and joined by the OS path separator."],"tags":["cli","filters","configuration","parameters-file","argument-conflict"],"backgroundTag":null,"analyzedSha":"3f348be3e33f5d72d414e3ad55839c2ba34dda67","analyzedAt":"2026-08-13T16:48:27.008Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}