]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/bin/pxar.rs
src/config/network.rs: make it compatible with pve
[proxmox-backup.git] / src / bin / pxar.rs
index 5d4b53c740fbbf5f66186738c4a89a84266bbf57..5d1eb2e63c2274d3b36c262212939f2364999296 100644 (file)
@@ -1,13 +1,13 @@
 extern crate proxmox_backup;
 
-use failure::*;
+use anyhow::{format_err, Error};
 
 use proxmox::{sortable, identity};
 use proxmox::api::{ApiHandler, ApiMethod, RpcEnvironment};
 use proxmox::api::schema::*;
+use proxmox::api::cli::*;
 
 use proxmox_backup::tools;
-use proxmox_backup::cli::*;
 
 use serde_json::{Value};
 
@@ -178,6 +178,7 @@ fn create_archive(
     let no_sockets = param["no-sockets"].as_bool().unwrap_or(false);
     let empty = Vec::new();
     let exclude_pattern = param["exclude"].as_array().unwrap_or(&empty);
+    let entries_max = param["entries-max"].as_u64().unwrap_or(pxar::ENCODER_MAX_ENTRIES as u64);
 
     let devices = if all_file_systems { None } else { Some(HashSet::new()) };
 
@@ -232,6 +233,7 @@ fn create_archive(
         false,
         feature_flags,
         pattern_list,
+        entries_max as usize,
     )?;
 
     writer.flush()?;
@@ -342,6 +344,15 @@ const API_METHOD_CREATE_ARCHIVE: ApiMethod = ApiMethod::new(
                     &StringSchema::new("Path or pattern matching files to restore.").schema()
                 ).schema()
             ),
+            (
+                "entries-max",
+                true,
+                &IntegerSchema::new("Max number of entries loaded at once into memory")
+                    .default(pxar::ENCODER_MAX_ENTRIES as isize)
+                    .minimum(0)
+                    .maximum(std::isize::MAX)
+                    .schema()
+            ),
         ]),
     )
 );
@@ -488,29 +499,26 @@ fn main() {
 
     let cmd_def = CliCommandMap::new()
         .insert("create", CliCommand::new(&API_METHOD_CREATE_ARCHIVE)
-            .arg_param(&["archive", "source", "exclude"])
+            .arg_param(&["archive", "source"])
             .completion_cb("archive", tools::complete_file_name)
             .completion_cb("source", tools::complete_file_name)
-            .into()
         )
         .insert("extract", CliCommand::new(&API_METHOD_EXTRACT_ARCHIVE)
-            .arg_param(&["archive", "pattern"])
+            .arg_param(&["archive", "target"])
             .completion_cb("archive", tools::complete_file_name)
             .completion_cb("target", tools::complete_file_name)
             .completion_cb("files-from", tools::complete_file_name)
-            .into()
-        )
+         )
         .insert("mount", CliCommand::new(&API_METHOD_MOUNT_ARCHIVE)
             .arg_param(&["archive", "mountpoint"])
             .completion_cb("archive", tools::complete_file_name)
             .completion_cb("mountpoint", tools::complete_file_name)
-            .into()
         )
         .insert("list", CliCommand::new(&API_METHOD_DUMP_ARCHIVE)
             .arg_param(&["archive"])
             .completion_cb("archive", tools::complete_file_name)
-            .into()
         );
 
-    run_cli_command(cmd_def.into());
+    let rpcenv = CliEnvironment::new();
+    run_cli_command(cmd_def, rpcenv, None);
 }