extern crate proxmox_backup;
use failure::*;
-use std::os::unix::io::AsRawFd;
+//use std::os::unix::io::AsRawFd;
use proxmox_backup::tools;
use proxmox_backup::cli::command::*;
//use proxmox_backup::backup::image_index::*;
//use proxmox_backup::config::datastore;
//use proxmox_backup::catar::encoder::*;
-use proxmox_backup::backup::datastore::*;
+//use proxmox_backup::backup::datastore::*;
use serde_json::{Value};
use hyper::Body;
.append_pair("time", &epoch.to_string())
.finish();
- let path = format!("api3/json/admin/datastore/{}/upload_catar?{}", store, query);
+ let path = format!("api2/json/admin/datastore/{}/catar?{}", store, query);
client.upload("application/x-proxmox-backup-catar", body, &path)?;
let mut target = PathBuf::from(target);
if let Some(ext) = target.extension() {
- if ext != "iidx" {
- bail!("got wrong file extension - expected '.iidx'");
+ if ext != "fidx" {
+ bail!("got wrong file extension - expected '.fidx'");
}
} else {
- target.set_extension("iidx");
+ target.set_extension("fidx");
}
let mut index = datastore.create_image_writer(&target, size, chunk_size)?;
}
*/
-fn create_backup(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
+fn list_backups(
+ param: Value,
+ _info: &ApiMethod,
+ _rpcenv: &mut RpcEnvironment,
+) -> Result<Value, Error> {
+
+ let store = tools::required_string_param(¶m, "store")?;
+
+ let client = HttpClient::new("localhost");
+
+ let path = format!("api2/json/admin/datastore/{}/backups", store);
+
+ let result = client.get(&path)?;
+
+ Ok(result)
+}
+
+fn create_backup(
+ param: Value,
+ _info: &ApiMethod,
+ _rpcenv: &mut RpcEnvironment,
+) -> Result<Value, Error> {
let filename = tools::required_string_param(¶m, "filename")?;
let store = tools::required_string_param(¶m, "store")?;
let target = tools::required_string_param(¶m, "target")?;
- let mut chunk_size = 4*1024*1024;
+ let mut _chunk_size = 4*1024*1024;
if let Some(size) = param["chunk-size"].as_u64() {
static SIZES: [u64; 7] = [64, 128, 256, 512, 1024, 2048, 4096];
if SIZES.contains(&size) {
- chunk_size = (size as usize) * 1024;
+ _chunk_size = (size as usize) * 1024;
} else {
bail!("Got unsupported chunk size '{}'", size);
}
println!("Backup image '{}' to '{}'", filename, store);
if stat.st_size <= 0 { bail!("got strange file size '{}'", stat.st_size); }
- let size = stat.st_size as usize;
+ let _size = stat.st_size as usize;
panic!("implement me");
fn main() {
- let cmd_def = CliCommand::new(
+ let create_cmd_def = CliCommand::new(
ApiMethod::new(
create_backup,
ObjectSchema::new("Create backup.")
.completion_cb("filename", tools::complete_file_name)
.completion_cb("store", proxmox_backup::config::datastore::complete_datastore_name);
+ let list_cmd_def = CliCommand::new(
+ ApiMethod::new(
+ list_backups,
+ ObjectSchema::new("List backups.")
+ .required("store", StringSchema::new("Datastore name."))
+ ))
+ .arg_param(vec!["store"])
+ .completion_cb("store", proxmox_backup::config::datastore::complete_datastore_name);
+
+
+ let cmd_def = CliCommandMap::new()
+ .insert("create".to_owned(), create_cmd_def.into())
+ .insert("list".to_owned(), list_cmd_def.into());
if let Err(err) = run_cli_command(&cmd_def.into()) {
eprintln!("Error: {}", err);