C#Duplicati Interface恢复单个文件

时间:2015-08-03 07:41:58

标签: c# mono restore duplicati

我正在尝试使用Duplicati API恢复单个文件。

关于场景:整个事情在linux上运行,所以它是用mono编译的。我的备份包含两个源文件夹,所以如果我运行Interface.ListSourceFolders(),我会得到一个两个数组。

期望的结果:我想从备份中恢复一个文件(或文件夹)

当前结果:如果我运行下面的代码,它会将所有备份的文件(文件夹1和文件夹2)恢复到//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());

我尝试了什么:我尝试将//Comment1的路径设置为绝对路径(/desired/file/to/restore)或使用源文件夹的索引({{1}我也在0/file/to/restore玩了一遍。例如我添加了类似//Comment2的内容。我总是得到相同的结果。

有谁看到我做错了什么?因为我不知道还能尝试什么。几乎没有文档,所以我不知道在哪里搜索。如果有人知道一个好文档的链接,我也会很开心!

1 个答案:

答案 0 :(得分:0)

如果有人有兴趣。经过几个小时的尝试后,我终于找到了如何只恢复单个文件或文件夹。这就是我现在正在做的事情:

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());

//Comment1,您需要设置所需的还原路径。在此文件夹中,将创建所有备份集文件夹(来自Interface.ListSourceFolders()的文件夹)

//Comment2,您可以使用以下格式指定要还原的文件:0/file/to/restore其中0是源文件夹的索引(Interface.ListSourceFolders())。如果您需要恢复多个文件,可以将它们组合成一个字符串: Windows:0/file1;1/file2或Linux 0/file1:1/file2(区别在于分号或冒号)

现在还有一件事:您无法使用其文件还原文件夹。您需要将上述字符串中的所有文件和子文件组合在一起。

我希望我可以帮助别人。

相关问题