How to delete some folder or/and files inside each backup version

I don’t want to store some files to security reason and want to reduce cloud space.

How I can do this?

Have you looked into the “Smart Backup Retention” or “Custom Backup Retention” options?

If you’re looking to get them out of an existing backup then draka2007’s suggestion could do it the easy way.

If you need to get things out right away then there are some command line options such as purge that can remove things immediately.

But if you want to keep the files from getting into the backup in the first place you should review your jobs filters on the “Source” step of editing a job.

1 Like

Thank you for command purge). I didn’t guess that this command do that I want (I hope).

I wiil write later about my result.

Can you help me to explain how to “purge” few or list of files?

Below is the help text for purge but I believe basically it would be to either run a command line like the following in a shell:

“C:\Program Files\Duplicati 2\Duplicati.CommandLine.exe” purge “googledrive:///MyBackups/Duplicati/GoogleDrive?authid=MyAuthID” File1ToBeDeleted.txt File2ToBeDeleted.exe --dbpath=""

Or in the GUI you could:

  • select the “Commandline …” job menu item-
  • select purge from the Command list
  • delete anything in “Commandline arguments”
  • click “Edit as text” across from “Advanced options” and deleted everything but --dbpath from there
  • in “Commandline arguments” put the files to be deleted OR use the --include=<filter>. In both causes put one per line
  • for testing, I suggest you START with also using the --dry-run flag, just to make sure you are not going to accidentally delete more than you want
  • click the blue “Run ‘purge’ command” button at the bottom of the page
Duplicati.CommandLine.exe help purge

Usage: purge <storage-URL> <filenames> [<options>]

  Purges (removes) files from remote backup data. This command can either take
  a list of filenames or use the filters to choose which files to purge. The
  purge process creates new filesets on the remote destination with the
  purged files removed, and will start the compacting process after a purge.
  By default, the matching files are purged in all versions, but this can be
  limited by choosing one or more versions. To test what will happen, use the
  --dry-run flag.

    Performs the operation, but does not write changes to the local database
    or the remote storage
    Selects specific versions to purge from, multiple versions can be
    specified with commas
    Selects a specific version to purge from
    Performs a compact process after purging files
    Selects files to purge, using filter syntax
1 Like

Thank you.

I tried to use this construction before had the qustion to you. But I see error: “Input passphrase” (on my native language, so may be in English it’s write another) and “System.InvalidOperationException: Can’t read keys when all applications don’t have console or input data was forwarded from file… Try to use Console.Read”.

If I add --passphrase parameter I see the same messages.

I add --dry-run to test it. May be problem in this.

Sorry, my mistake and incorrect D2 error message. I forgot to add to filename to excluding folder.

OK. I added filenames and there are some stranges.

  1. May be my mistake again, but my saved pass is not equal to pass when export either in parameters of command.
  2. Pass from export is not equal to pass in parameters.
  3. May be due 1 and 2 I see in CLI: “You have attempted to change a passphrase to an existing backup, which is not supported. Please configure a new clean backup if you want to change the passphrase.”
  4. OK. I tried to use “purge” in GUI. After deleting “–exclude” parameters I saw:
    “System.IO.IOException: The source folder C:\Bases 1C\1С Бухгалтерия (2015)\1Cv8.1CD does not exist, aborting backup
    в Duplicati.Library.Main.Controller.ExpandInputSources(String[] inputsources, IFilter filter)
    в Duplicati.Library.Main.Controller.<>c__DisplayClass15_0.b__0(BackupResults result)
    в Duplicati.Library.Main.Controller.RunAction[T](T result, String[]& paths, IFilter& filter, Action1 method) в Duplicati.Library.Main.Controller.Backup(String[] inputsources, IFilter filter) в Duplicati.CommandLine.Commands.Backup(TextWriter outwriter, Action1 setup, List1 args, Dictionary2 options, IFilter filter)
    в Duplicati.CommandLine.Program.RunCommandLine(TextWriter outwriter, TextWriter errwriter, Action`1 setup, String[] args)”.
    So folder must exist, right?

I don’t understand what I do wrong.

Oh… I found a correct pass and “purge” works fine in GUI, but I doesn’t work in CUI. Do you know prohibited symbols in pass? Because my pass end with “” and export to command line add “” to my passphrase.

But It doesn’t work with “purge”.

I’m glad you got it working at least via the GUI.

I am not sure about the correct way to escape characters for command line calls as I’ve never needed to do it - though I would guess it varies depending on the OS involved.

1 Like

Unfortenutely, I don’t understand now how it worked before. Now I can’t use GUI and have the same problem.

I check my pass with forwarding from one cmd to another and I found that I must only double “%” in my pass.

Oh… I think I have to create new backup without any special symbols (((.

If D2 see pass in CUI I will find a better solution to escaping. May be you know solution for it?
But now it’s like a looking black cat in a black house at night)).

Problem with GUI due autofill in the browser. I did it on another computer with success.
With CUI I have no success.

So big thank you for you pattience.

One way around commandline escape/encoding issues is to use --parameter-file=C:\myargs.txt, then edit the file and make it look like this:


Preferably, save the file with UTF-8 encoding (include BOM), just to be sure.

You can add more options if you want, just add each option on a line by itself, and then invoke Duplicati with:

“C:\Program Files\Duplicati 2\Duplicati.CommandLine.exe” purge “googledrive:///MyBackups/Duplicati/GoogleDrive?authid=MyAuthID” File1ToBeDeleted.txt File2ToBeDeleted.exe --parameter-file=C:\myargs.txt

Thank you!!!

And how I can delete folder with subfolders and files inside them?

I’ve not tried it myself, but according to the purge command docs you can use --include filters with the purge command so that would likely be the easiest way to do it.

I tried many variants besides include, but without any success. And it’s strange but when I do find command with all versions I don’t see my files, that I want to delete.
But I see it in backup version 2. I don’t understand why. May be problem in this.

Thank you for wanting to help. All work find without include filters. I wrote like a “C:\Path\*” instead .

Problem in dry-run wrote only “Listing folders” without some more information about founded and deleted files.

I ran without dry-run with success.


So I hope it worked. I accidentally included a folder “c:\Disk\WD50\Games_Programme” - now I’d like to remove all this from a huge backup via purge. And I remember until now it never worked for me, error messages, it was close to impossible to remove stuff from backups.

I have recently been struggling with getting Purge to work, but eventually managed. Since this is one of the first results in Google search, I thought I’d share my finding for future code wanderers :+1:


Remove all instances backups of specific files from a Duplicati backup.

  1. In the GUI select CommandLine on the backup you want
  2. Select Purge at the top (warning, this will reset each time you come back to this page!)
  3. In Commandline Arguments enter the full path to the file(s)
    • Separated by a new line each
    • Use the full file path. E.g: /home/myuser/long/file/path/to/the/place/badfile.mp4
    • Can use * as wildcard to delete multiple. E.g: /home/myuser/long/file/path/to/the/place/*.mp4 will delete all mp4s in that folder
  4. Can use --include [regex] instead of the the arguments.
    • Just delete all content in the arguments, click edit as text, and add this at the bottom.
    • Regex must be surrounded in square brackets.
    • Do not use quotes.
  5. --dry-run is also available but gives no feedback for a remote repo so it is essentially useless for a Purge

Best of luck all :four_leaf_clover: