src/bin/proxmox-backup-client.rs: impl option all-file-systems
This commit is contained in:
parent
06178f13fa
commit
eed6db3923
@ -144,7 +144,7 @@ fn create_archive(
|
|||||||
|
|
||||||
let mut writer = std::io::BufWriter::with_capacity(1024*1024, file);
|
let mut writer = std::io::BufWriter::with_capacity(1024*1024, file);
|
||||||
|
|
||||||
CaTarEncoder::encode(source, &mut dir, all_file_systems, &mut writer, verbose)?;
|
CaTarEncoder::encode(source, &mut dir, &mut writer, all_file_systems, verbose)?;
|
||||||
|
|
||||||
writer.flush()?;
|
writer.flush()?;
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ fn backup_directory<P: AsRef<Path>>(
|
|||||||
backup_id: &str,
|
backup_id: &str,
|
||||||
backup_time: DateTime<Local>,
|
backup_time: DateTime<Local>,
|
||||||
chunk_size: Option<u64>,
|
chunk_size: Option<u64>,
|
||||||
|
all_file_systems: bool,
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ fn backup_directory<P: AsRef<Path>>(
|
|||||||
|
|
||||||
let path = format!("api2/json/admin/datastore/{}/catar?{}", repo.store, query);
|
let path = format!("api2/json/admin/datastore/{}/catar?{}", repo.store, query);
|
||||||
|
|
||||||
let stream = CaTarBackupStream::open(dir_path.as_ref(), verbose)?;
|
let stream = CaTarBackupStream::open(dir_path.as_ref(), all_file_systems, verbose)?;
|
||||||
|
|
||||||
let body = Body::wrap_stream(stream);
|
let body = Body::wrap_stream(stream);
|
||||||
|
|
||||||
@ -298,6 +299,8 @@ fn create_backup(
|
|||||||
|
|
||||||
let repo = BackupRepository::parse(repo_url)?;
|
let repo = BackupRepository::parse(repo_url)?;
|
||||||
|
|
||||||
|
let all_file_systems = param["all-file-systems"].as_bool().unwrap_or(false);
|
||||||
|
|
||||||
let verbose = param["verbose"].as_bool().unwrap_or(false);
|
let verbose = param["verbose"].as_bool().unwrap_or(false);
|
||||||
|
|
||||||
let chunk_size_opt = param["chunk-size"].as_u64().map(|v| v*1024);
|
let chunk_size_opt = param["chunk-size"].as_u64().map(|v| v*1024);
|
||||||
@ -352,7 +355,8 @@ fn create_backup(
|
|||||||
|
|
||||||
for (filename, target) in upload_list {
|
for (filename, target) in upload_list {
|
||||||
println!("Upload '{}' to '{:?}' as {}", filename, repo, target);
|
println!("Upload '{}' to '{:?}' as {}", filename, repo, target);
|
||||||
backup_directory(&mut client, &repo, &filename, &target, backup_id, backup_time, chunk_size_opt, verbose)?;
|
backup_directory(&mut client, &repo, &filename, &target, backup_id, backup_time,
|
||||||
|
chunk_size_opt, all_file_systems, verbose)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let end_time = Local.timestamp(Local::now().timestamp(), 0);
|
let end_time = Local.timestamp(Local::now().timestamp(), 0);
|
||||||
|
@ -43,8 +43,8 @@ impl <'a, W: Write> CaTarEncoder<'a, W> {
|
|||||||
pub fn encode(
|
pub fn encode(
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
dir: &mut nix::dir::Dir,
|
dir: &mut nix::dir::Dir,
|
||||||
all_file_systems: bool,
|
|
||||||
writer: &'a mut W,
|
writer: &'a mut W,
|
||||||
|
all_file_systems: bool,
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ impl Drop for CaTarBackupStream {
|
|||||||
|
|
||||||
impl CaTarBackupStream {
|
impl CaTarBackupStream {
|
||||||
|
|
||||||
pub fn new(mut dir: Dir, path: PathBuf, verbose: bool) -> Result<Self, Error> {
|
pub fn new(mut dir: Dir, path: PathBuf, all_file_systems: bool, verbose: bool) -> Result<Self, Error> {
|
||||||
let mut buffer = Vec::with_capacity(4096);
|
let mut buffer = Vec::with_capacity(4096);
|
||||||
unsafe { buffer.set_len(buffer.capacity()); }
|
unsafe { buffer.set_len(buffer.capacity()); }
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ impl CaTarBackupStream {
|
|||||||
|
|
||||||
let child = thread::spawn(move|| {
|
let child = thread::spawn(move|| {
|
||||||
let mut writer = unsafe { std::fs::File::from_raw_fd(tx) };
|
let mut writer = unsafe { std::fs::File::from_raw_fd(tx) };
|
||||||
if let Err(err) = CaTarEncoder::encode(path, &mut dir, false, &mut writer, verbose) {
|
if let Err(err) = CaTarEncoder::encode(path, &mut dir, &mut writer, all_file_systems, verbose) {
|
||||||
eprintln!("catar encode failed - {}", err);
|
eprintln!("catar encode failed - {}", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -54,12 +54,12 @@ impl CaTarBackupStream {
|
|||||||
Ok(Self { pipe: Some(pipe), buffer, child: Some(child) })
|
Ok(Self { pipe: Some(pipe), buffer, child: Some(child) })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open(dirname: &Path, verbose: bool) -> Result<Self, Error> {
|
pub fn open(dirname: &Path, all_file_systems: bool, verbose: bool) -> Result<Self, Error> {
|
||||||
|
|
||||||
let dir = nix::dir::Dir::open(dirname, OFlag::O_DIRECTORY, Mode::empty())?;
|
let dir = nix::dir::Dir::open(dirname, OFlag::O_DIRECTORY, Mode::empty())?;
|
||||||
let path = std::path::PathBuf::from(dirname);
|
let path = std::path::PathBuf::from(dirname);
|
||||||
|
|
||||||
Self::new(dir, path, verbose)
|
Self::new(dir, path, all_file_systems, verbose)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user