How to use backup json file with duplicati-cli?

Hi,
I have saved my backup process under a json file to be able to backup and restore again with the same backup configuration on different servers with approximately the same source and targets.
I can import the file in the duplicati gui but I would like to use duplicati-cli to automate the backup using this json file to specify the target, source, password and other options.
Is this possible?
Thank you

Hello

sure why not ? use the create function.

Welcome to the forum @a.p.

Perhaps you could clarify the “any computer” part. Any backup configuration is computer-specific and shouldn’t be used on more than one computer at a time. You don’t want backups mixed at destination.

Export As Command-line will make it ready for independent duplicati-cli backup, but beware of above…

1 Like

Hi,
Thanks for your answers, i found what i was looking for with the export as command-line option.
However this works to make a backup, but is there an equivalent to restore a backup with the command line?
thanks

The RESTORE command. Start from your backup command line and remove/convert into a restore.

Ok thanks.
I see in the documentation
--version=<int>
Restore files from a specific backup.
How do i know which integer is associated with which backup ?

The FIND command (list is a synonym)

If no <filename> is specified, a list of all available backups is shown.

The version number is on the left (true for GUI Restore too). CLI output:

Listing filesets:
0       : 1/10/2023 8:46:03 AM (6 files, 785 bytes)
1       : 1/6/2023 5:11:49 PM (6 files, 785 bytes)

Ok thanks a lot, im almost all set now.
I would like now to use the cli to create a backup, but the backup is not listed in the gui.
Can I do that? I dont find a command appropriate in the documentation, i have tried create command but not working

CLI runs independently of GUI unless you connect them, for example with same database.
This is easy if you base the CLI run on the GUI export, as GUI dbpath is part of the export.
Don’t expect CLI work to update ALL the GUI info, but it’s a pleasant way to do the restore.

Ah thank you, indeed i see i can use the cli without the dbpath flag…
But in that case does the cli still use a database to keep track of the backups and restore?

Yes. It assigns a DB which is (I think) tied to the destination URL.
Look in ~<user>/.config/Duplicati/dbconfig.json to know or tweak

thanks a lot for your time and explanations!

1 Like

I actually still have a question : why does the cli download files after Verifying remote backup when backing up files on a remote swift cloud storage? :
Backup started at 11/01/2023 18:37:08
Checking remote backup …
Listing remote folder …
Scanning local files …
0 files need to be examined (0 octets)
34575 files need to be examined (1,08 GB)
33953 files need to be examined (984,46 MB)
30503 files need to be examined (938,01 MB)
28978 files need to be examined (836,40 MB)
26141 files need to be examined (684,16 MB)
21799 files need to be examined (609,73 MB)
19382 files need to be examined (518,59 MB)
16734 files need to be examined (456,81 MB)
12552 files need to be examined (412,60 MB)
8356 files need to be examined (377,76 MB)
5664 files need to be examined (347,25 MB)
5013 files need to be examined (0 octets)
Uploading file (99,95 MB) …
Uploading file (99,93 MB) …
Uploading file (58,68 MB) …
0 files need to be examined (0 octets)
Uploading file (452,01 KB) …
Uploading file (723,09 KB) …
Uploading file (904,45 KB) …
Uploading file (1,54 MB) …
Checking remote backup …
Listing remote folder …
Verifying remote backup …
Remote backup verification completed
Downloading file (1,54 MB) …
Downloading file (452,01 KB) …
Downloading file (99,95 MB) …
Duration of backup: 00:18:45
Remote files: 7
Remote size: 262,13 MB
Total remote quota: 0 octets
Available remote quota: 0 octets
Files added: 30492
Files deleted: 0
Files changed: 0
Data uploaded: 262,13 MB
Data downloaded: 101,93 MB
Backup completed successfully!

Verifying backend files

At the end of each backup job, Duplicati checks the integrity by downloading a few files from the backend. The contents of these file is checked against what Duplicati expects it to be. This procedure increases the reliability of the backup files, but backups take a bit longer to complete and use some download bandwidth.

Remote backup verification completed message before rather than after its verification might be a display glitch. I don’t recall it sequencing like that on the GUI status line, but it’s implemented differently. Possibly CLI held some text in a buffer that it didn’t actually flush to the console until somewhat too late.

EDIT:

The TEST command explains further and gives options, if you’re not happy with the default of one “set”.

Ok thanks again :wink:
I still have a question regarding the duplicati cli while running tests :
when i do a backup and immediatly do a restore without specifying a dbpath, the cli tries to do a restore! does it need a dbpath to understand it doesnt need a restore?
also when the path of the restore is different from the path of the backup it seems it tries to do a restore but it results in stating nothing was restored…
Im a bit confused it doesnt seem very reliable

First, if you ask for a restore and restore begins, it did what you asked. See finer points on restore below.

Second, if you backed up with a dbpath and restored without, there’s no telling what’s in the old database that the CLI got. It might have different source files, might not match destination now (a requirement), etc.

Any CLI operation that uses a database and is expected to use the GUI database must get GUI database by means of dbpath, otherwise it will use whatever old CLI database is laying around from a previous CLI operation that failed to give a dbpath. If you don’t know if database is used, give it anyway. It won’t hurt…

What’s at the path of the restore? If it’s exactly what restore would do, no need for file restore.
Restore is not a file copy. It makes the restore location the way you ask in an efficient manner.
If you’re restoring onto a file that’s an old version that’s mostly right, it will just patch in change.
There is zero point in spending download and CPU resources fixing something that’s OK now.

Also keep in mind that without GUI dbpath, CLI restore is restoring some unknown old backup.
The FIND command done the same way (e.g. without dbpath) can show its content if you want.

EDIT:

Another way to get this is to incorrectly list what to restore. What did you list? The GUI is easier.

EDIT 2:

I believe selecting a folder in GUI restores things below it. CLI probably needs wildcard * at end.

Back to the nothing-needed message, full message would probably be as below. See initial text:

Restore completed without errors but no files were restored

If you get the syntax right to do a CLI restore, doing another one just like it should say the above.
That means everything was fine already. No changes required.

OK thanks again for your time and answer
Well I dont understand why it tells me “Restore completed without errors but no files were restored” AFTER it downloads everything in the backup! if the cli first compares what’s in the backup to what’s on my path, why does it need to download everything ?

Please show me how you know it downloaded everything. I doubt that’s the case. It’s quite particular.

EDIT:

The database should know what the source looks like. As always, make sure you’re giving cli dbpath.

ok i will try again with dbpath.
however, for the first backup, can i define a random dbpath name? or how is it initiated?

Not if you want it to use the GUI database. That’s why everyone keeps telling you things like:

If you didn’t care about connecting to the GUI backup, then pick any accessible path you like.
Consistency is important. If you pick it, use it always. If Duplicati cli assigns it, it remembers it.

EDIT:

And if you go with an assigned-by-you or assigned-by-cli database that isn’t there, it builds it:

The operation Restore has started
No local database, building a temporary database

then the database creation will download a bunch of dlist files, then a bunch of dindex files.
Your original source file data and attributes are in dblock files, and a few will download to get
attributes I believe, but that’s typically far less than the source file size. Another shortcut is this:

no-local-blocks

Duplicati will attempt to use data from source files to minimize the amount of downloaded data. Use this option to skip this optimization and only use remote data.

which means backup and immediate restore should by default be able to get data from source.
You can look in the destination to note its files, then run cli with –console-log-level=information.
I would be very surprised if it downloads everything, but there’s no post on what it downloaded.