diff --git a/replibyte/src/cli.rs b/replibyte/src/cli.rs index f7713b87..5026c534 100644 --- a/replibyte/src/cli.rs +++ b/replibyte/src/cli.rs @@ -94,7 +94,7 @@ pub struct RestoreLocalArgs { /// all backup run commands #[derive(Args, Debug)] pub struct DumpCreateArgs { - #[clap(name = "source_type", short, long, value_name = "[postgresql | mysql]", possible_values = &["postgresql", "mysql"], requires = "input")] + #[clap(name = "source_type", short, long, value_name = "[postgresql | mysql | mongodb]", possible_values = &["postgresql", "mysql", "mongodb"], requires = "input")] /// database source type to import pub source_type: Option, /// import dump from stdin diff --git a/replibyte/src/commands/dump.rs b/replibyte/src/commands/dump.rs index d7bc5139..37ddb452 100644 --- a/replibyte/src/commands/dump.rs +++ b/replibyte/src/commands/dump.rs @@ -20,6 +20,7 @@ use crate::destination::postgres_docker::{ DEFAULT_POSTGRES_IMAGE_TAG, DEFAULT_POSTGRES_PASSWORD, DEFAULT_POSTGRES_USER, }; use crate::source::mongodb::MongoDB; +use crate::source::mongodb_stdin::MongoDBStdin; use crate::source::mysql::Mysql; use crate::source::mysql_stdin::MysqlStdin; use crate::source::postgres::Postgres; @@ -182,6 +183,18 @@ where let task = FullDumpTask::new(mysql, datastore, options); task.run(progress_callback)? } + Some(v) if v == "mongodb" => { + if args.file.is_some() { + let dump_file = File::open(args.file.as_ref().unwrap())?; + let mut stdin = stdin(); // FIXME + let reader = BufReader::new(dump_file); + let _ = stdin.read_to_end(&mut reader.buffer().to_vec())?; + } + + let mongodb = MongoDBStdin::default(); + let task = FullDumpTask::new(mongodb, datastore, options); + task.run(progress_callback)? + } Some(v) => { return Err(anyhow::Error::from(Error::new( ErrorKind::Other,