0

I'm trying to use the Duplicati API to restore a single file.

About the Scenario: The whole thing runs on linux so it is compiled with mono. My backup contains two source Folders, so if I run Interface.ListSourceFolders() I get an Array of two.

Desired result: I want to restore one single file (or Folder) from my backup

Current result: If I run the code below it restores all the backed up files (so Folder 1 and Folder 2) into the path in //Comment1.

List<string> files = new List<string>();
files.Add("path");    //Comment1

Dictionary<string,string> options = new Dictionary<string,string>();
options["passphrase"] = MySettings.Password;
options["restore-time"] = date;
//Comment2

Interface i = new Interface("file:///path/to/archives", options);
string result = i.Restore(files.ToArray());

What I tried: I tried to set the path at //Comment1 to the absolute path (/desired/file/to/restore) or using the index of the source Folder (0/file/to/restore) and I also played around at //Comment2. e.g. I added something like options["restore-path"] = "/path/to/restore". I always get the same result.

Does anyone see what I'm doing wrong? Because I don't know what else I could try. There is almost no documentation so I don't know where to search. If someone knows a link for a good documentation I would be happy too!

Thomas Sparber
  • 2,827
  • 2
  • 18
  • 34

1 Answers1

0

In case if someone is interested. After trying around for hours I finally found out how to restore just a single file or folder. Here is what I'm doing now:

List<string> files = new List<string>();
files.Add("/restore/path");    //Comment1

Dictionary<string,string> options = new Dictionary<string,string>();
options["passphrase"] = MySettings.Password;
options["restore-time"] = date;
options["file-to-restore"] = "files";    //Comment2

Interface i = new Interface("file:///path/to/archives", options);
string result = i.Restore(files.ToArray());

At //Comment1 you need to set the desired restore path. In this folder all backup-set-folders are created (The folders from Interface.ListSourceFolders())

At //Comment2 you can specify the files to be restored in this form: 0/file/to/restore where 0 is the index of the source folder (Interface.ListSourceFolders()). If you need to restore multiple files you can do it by combining them into one string: e.g. Windows: 0/file1;1/file2 or Linux 0/file1:1/file2 (The difference is semicolon or colon)

Now there is just one more thing: You can not restore a folder with its files. You need to combine all files and sub-files in the string mentioned above.

I hope I could help somebody.

Thomas Sparber
  • 2,827
  • 2
  • 18
  • 34