fix: SystemZfs uses sudo for write ops (snapshot/destroy/clone/send)
This commit is contained in:
@@ -20,8 +20,8 @@ pub struct SystemZfs;
|
||||
impl ZfsOps for SystemZfs {
|
||||
fn snapshot(&self, dataset: &str, tag: &str) -> Result<()> {
|
||||
let name = format!("{}@{}", dataset, tag);
|
||||
let out = std::process::Command::new("zfs")
|
||||
.args(["snapshot", &name])
|
||||
let out = std::process::Command::new("sudo")
|
||||
.args(["zfs", "snapshot", &name])
|
||||
.output()
|
||||
.context("running zfs snapshot")?;
|
||||
if !out.status.success() {
|
||||
@@ -46,8 +46,8 @@ impl ZfsOps for SystemZfs {
|
||||
}
|
||||
|
||||
fn delete_snapshot(&self, full_name: &str) -> Result<()> {
|
||||
let out = std::process::Command::new("zfs")
|
||||
.args(["destroy", full_name])
|
||||
let out = std::process::Command::new("sudo")
|
||||
.args(["zfs", "destroy", full_name])
|
||||
.output()
|
||||
.context("running zfs destroy")?;
|
||||
if !out.status.success() {
|
||||
@@ -59,14 +59,14 @@ impl ZfsOps for SystemZfs {
|
||||
fn send_to_remote(&self, snapshot: &str, incremental_from: Option<&str>,
|
||||
remote_user: &str, remote_host: &str,
|
||||
remote_dataset: &str) -> Result<()> {
|
||||
let mut send_args = vec!["send".to_string()];
|
||||
let mut send_args = vec!["sudo".to_string(), "zfs".to_string(), "send".to_string()];
|
||||
if let Some(prev) = incremental_from {
|
||||
send_args.push("-i".to_string());
|
||||
send_args.push(prev.to_string());
|
||||
}
|
||||
send_args.push(snapshot.to_string());
|
||||
let cmd = format!(
|
||||
"zfs {} | ssh {}@{} zfs receive -F {}",
|
||||
"{} | ssh {}@{} sudo zfs receive -F {}",
|
||||
send_args.join(" "), remote_user, remote_host, remote_dataset
|
||||
);
|
||||
let out = std::process::Command::new("sh")
|
||||
@@ -80,8 +80,8 @@ impl ZfsOps for SystemZfs {
|
||||
}
|
||||
|
||||
fn clone_snapshot(&self, snapshot: &str, dest_dataset: &str) -> Result<()> {
|
||||
let out = std::process::Command::new("zfs")
|
||||
.args(["clone", snapshot, dest_dataset])
|
||||
let out = std::process::Command::new("sudo")
|
||||
.args(["zfs", "clone", snapshot, dest_dataset])
|
||||
.output()
|
||||
.context("running zfs clone")?;
|
||||
if !out.status.success() {
|
||||
|
||||
Reference in New Issue
Block a user