Questions about command line use and --keep-versions

Hello! I’m setting up Duplicati’s command line for use in scripts (Windows) and could use a little help understanding how to keep only the most recent copy of the data.

I understand that you use the “backup” command to make a backup. That’s obvious enough. But does the backup command delete old data and compact the dblock files?

Do I need to run the “delete” command after “backup” if I want that to happen? Or what do I need to use?

The default value for “keep-versions” is 0; does that mean it only keeps the latest version, or does it mean that it keeps ALL versions (as a comment I read on Github suggested)?

You don’t have to use the delete command, --keep-time and --keep-versions will delete backups automatically after a number of days or when more than the specified number of versions exist.
After deleting backups, compacting is triggered to free up storage space at the backend. This is all done when executing the backupcommand.

--keep-versions=1 will keep only one version, --keep-versions=0 will keep all versions.
Why do you want to keep only one version? This is not recommended and quite unsafe. If you discover that you deleted an imported file just after you ran the backup, your file will be lost forever.
Duplicati is very storage space-friendly. I have several backups with more than 150 versions that still consume less storage space at the backend than the original files on the source disk.

Thanks for your interest in Duplicati!

Did you check out this topic, which is basically just a post of all the command line help output?

If you want to essentially turn off Duplicati’s version backups (so only keep the most recent version of a file) then you’ll want to use --keep-versions=1 which basically automatically do the delete command for any version older than the current.

Note that the delete command doesn’t necessarily actually delete the versions from the archive - it just flags them as “outdated”. Once enough outdated (aka deleteable) versions have accumulated (see --threshold, --small-file-size, and --small-file-max-count settings).

If you want to FORCE the cleanup of outdated versions after every backup then you’ll likely want to run the compact command, though you could probably get similar functionality automatically via judicious settings of the threshold and small-file parameters mentioned above.

Note that using Duplicati in this fashion will likely cause a lot of transfers to/from your destination due to all the cleanup being asked of it, so keep that in mind if you’re using a slow or bandwidth costly destination!

Darn - I knew I needed to type faster! :wink:

I see, so the backup command itself does the compaction when it’s appropriate, and keep-versions is a valid argument for it. Thank you very much!

As for why… I’m aiming to use it more as an incremental, compressed synchronization technique than for actual “backups”, and it has advantages over what you might think of for that scenario (rsync) such as its S3 connectivity. Keeping a few more versions than 1 wouldn’t be bad, but of course I don’t want it to get to 1000 and slow way down.

I did study the command line, yeah. The help for the “backup” command doesn’t really explain that it performs compaction or that --keep-versions is a valid argument for it, though that’s in the advanced help.

1 Like