Configure remote hosts in the TOML file now
This commit is contained in:
parent
670339d2c9
commit
ec278f954f
@ -56,7 +56,7 @@ pub enum DatmanCommand {
|
|||||||
/// Name of the destination to back up to.
|
/// Name of the destination to back up to.
|
||||||
destination_name: String,
|
destination_name: String,
|
||||||
|
|
||||||
/// Specify the remote user@host name.
|
/// Specify the remote name.
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
remote: Option<String>,
|
remote: Option<String>,
|
||||||
},
|
},
|
||||||
@ -164,7 +164,13 @@ fn main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(remote_user_at_host) = remote {
|
if let Some(remote_name) = remote {
|
||||||
|
let remote_host_descriptor =
|
||||||
|
if let Some(rhd) = descriptor.remote_hosts.get(&remote_name) {
|
||||||
|
rhd
|
||||||
|
} else {
|
||||||
|
bail!("No remote found by that name.");
|
||||||
|
};
|
||||||
backup_remote_source_to_destination(
|
backup_remote_source_to_destination(
|
||||||
source,
|
source,
|
||||||
destination,
|
destination,
|
||||||
@ -172,7 +178,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
Path::new("."),
|
Path::new("."),
|
||||||
&source_name,
|
&source_name,
|
||||||
&destination_name,
|
&destination_name,
|
||||||
&remote_user_at_host,
|
remote_host_descriptor,
|
||||||
yama::utils::get_number_of_workers("YAMA_CHUNKERS"),
|
yama::utils::get_number_of_workers("YAMA_CHUNKERS"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -48,6 +48,7 @@ pub fn init_descriptor(path: &Path) -> anyhow::Result<()> {
|
|||||||
],
|
],
|
||||||
source,
|
source,
|
||||||
piles: Default::default(),
|
piles: Default::default(),
|
||||||
|
remote_hosts: Default::default(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
datman_toml_file.write_all(&bytes)?;
|
datman_toml_file.write_all(&bytes)?;
|
||||||
|
@ -36,6 +36,14 @@ pub struct Descriptor {
|
|||||||
|
|
||||||
/// Paths to destination Yama Piles. Remote Piles need a local virtual pile to specify the layers.
|
/// Paths to destination Yama Piles. Remote Piles need a local virtual pile to specify the layers.
|
||||||
pub piles: HashMap<String, DestPileDescriptor>,
|
pub piles: HashMap<String, DestPileDescriptor>,
|
||||||
|
|
||||||
|
pub remote_hosts: HashMap<String, RemoteHostDescriptor>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
|
pub struct RemoteHostDescriptor {
|
||||||
|
pub user_at_host: String,
|
||||||
|
pub path_to_datman: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::commands::backup::{get_pointer_name_at, label_filter_and_convert};
|
use crate::commands::backup::{get_pointer_name_at, label_filter_and_convert};
|
||||||
use crate::descriptor::{Descriptor, DestPileDescriptor, SourceDescriptor};
|
use crate::descriptor::{Descriptor, DestPileDescriptor, RemoteHostDescriptor, SourceDescriptor};
|
||||||
use crate::tree::FileTree;
|
use crate::tree::FileTree;
|
||||||
use anyhow::{anyhow, bail};
|
use anyhow::{anyhow, bail};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
@ -80,7 +80,7 @@ pub fn backup_remote_source_to_destination(
|
|||||||
desc_path: &Path,
|
desc_path: &Path,
|
||||||
source_name: &str,
|
source_name: &str,
|
||||||
dest_name: &str,
|
dest_name: &str,
|
||||||
user_at_host: &str,
|
remote_host_descriptor: &RemoteHostDescriptor,
|
||||||
_num_workers: u8,
|
_num_workers: u8,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
match source {
|
match source {
|
||||||
@ -90,11 +90,11 @@ pub fn backup_remote_source_to_destination(
|
|||||||
} => {
|
} => {
|
||||||
info!(
|
info!(
|
||||||
"Looking to backup {} (from {}) to {}",
|
"Looking to backup {} (from {}) to {}",
|
||||||
source_name, user_at_host, dest_name
|
source_name, remote_host_descriptor.user_at_host, dest_name
|
||||||
);
|
);
|
||||||
|
|
||||||
let connection = Command::new("ssh")
|
let connection = Command::new("ssh")
|
||||||
.arg(user_at_host)
|
.arg(&remote_host_descriptor.user_at_host)
|
||||||
.arg("--")
|
.arg("--")
|
||||||
.arg("datman")
|
.arg("datman")
|
||||||
.arg("_backup_source_responder")
|
.arg("_backup_source_responder")
|
||||||
|
Loading…
Reference in New Issue
Block a user