I am trying to automate some mongobackups and restores. For which I am using rust for learning purposes as well.
fn dump(name: &str, user: &str, pass: &str, root: &settings::Root) {
let cmd = format!("mongodump -u {} -p{} --authenticationDatabase=admin --db={} --gzip --archive={}{}.archive", root.user, root.pass, name, name, get_time() );
println!("{}", cmd);
let output = Command::new(cmd).output();
match output {
Ok(res) => {
println!("{:?}", res);
},
Err(err) => {
println!("{}",err);
panic!(err);
}
}
}
This is the function for running the mongodump command.
I can see the print of cmd which is
mongodump -u manish -pterminator --authenticationDatabase=admin --db=todos --gzip --archive=todos16-Jan-2021-23:15:02.archive
which works fine if run directly in terminal, but fails in the program with error
No such file or directory (os error 2)
I have done multiple hit and trials but can't get it working.