C# Duplicati Interface 恢复单个文件
C# Duplicati Interface restore single file
我正在尝试使用 Duplicati API 来恢复单个文件。
关于场景:整个运行在linux上,所以它是用单声道编译的。我的备份包含两个源文件夹,所以如果我 运行 Interface.ListSourceFolders()
我得到一个包含两个的数组。
想要的结果:我想从我的备份中恢复一个文件(或文件夹)
当前结果:如果我运行下面的代码将所有备份文件(因此文件夹1和文件夹2)恢复到[=12中的路径=].
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
) 或使用源文件夹的索引(0/file/to/restore
) 我也在 //Comment2
玩过。例如我添加了类似 options["restore-path"] = "/path/to/restore"
的内容。我总是得到相同的结果。
有人看到我做错了什么吗?因为我不知道我还能尝试什么。几乎没有文档,所以我不知道去哪里搜索。如果有人知道 link 的好文档,我也会很高兴!
以防万一有人感兴趣。尝试了几个小时后,我终于找到了如何只恢复单个文件或文件夹的方法。这是我现在正在做的事情:
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
or Linux 0/file1:1/file2
(区别是分号还是冒号)
现在只有一件事:您无法恢复文件夹及其文件。您需要合并上述字符串中的所有文件和子文件。
我希望我能帮助到别人。
我正在尝试使用 Duplicati API 来恢复单个文件。
关于场景:整个运行在linux上,所以它是用单声道编译的。我的备份包含两个源文件夹,所以如果我 运行 Interface.ListSourceFolders()
我得到一个包含两个的数组。
想要的结果:我想从我的备份中恢复一个文件(或文件夹)
当前结果:如果我运行下面的代码将所有备份文件(因此文件夹1和文件夹2)恢复到[=12中的路径=].
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
) 或使用源文件夹的索引(0/file/to/restore
) 我也在 //Comment2
玩过。例如我添加了类似 options["restore-path"] = "/path/to/restore"
的内容。我总是得到相同的结果。
有人看到我做错了什么吗?因为我不知道我还能尝试什么。几乎没有文档,所以我不知道去哪里搜索。如果有人知道 link 的好文档,我也会很高兴!
以防万一有人感兴趣。尝试了几个小时后,我终于找到了如何只恢复单个文件或文件夹的方法。这是我现在正在做的事情:
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
or Linux 0/file1:1/file2
(区别是分号还是冒号)
现在只有一件事:您无法恢复文件夹及其文件。您需要合并上述字符串中的所有文件和子文件。
我希望我能帮助到别人。