diff --git a/.gitignore b/.gitignore index 27fafc3..c10c543 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ /dumps /.env /restore-assistant.log - +/rsdb.log diff --git a/Cargo.lock b/Cargo.lock index 0a51db1..37e94e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2130,35 +2130,6 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" -[[package]] -name = "restore-assistant" -version = "0.1.0" -dependencies = [ - "anyhow", - "aws-config", - "aws-credential-types", - "aws-sdk-s3", - "bytesize", - "chrono", - "clap", - "crossterm", - "dirs", - "dotenvy", - "flate2", - "futures-util", - "ratatui", - "rpassword", - "serde", - "serde_yaml", - "thiserror", - "tokio", - "toml", - "tracing", - "tracing-appender", - "tracing-subscriber", - "zstd", -] - [[package]] name = "rfc6979" version = "0.4.0" @@ -2194,6 +2165,35 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "rsdb" +version = "0.1.0" +dependencies = [ + "anyhow", + "aws-config", + "aws-credential-types", + "aws-sdk-s3", + "bytesize", + "chrono", + "clap", + "crossterm", + "dirs", + "dotenvy", + "flate2", + "futures-util", + "ratatui", + "rpassword", + "serde", + "serde_yaml", + "thiserror", + "tokio", + "toml", + "tracing", + "tracing-appender", + "tracing-subscriber", + "zstd", +] + [[package]] name = "rtoolbox" version = "0.0.5" diff --git a/Cargo.toml b/Cargo.toml index 9f69a1d..cb9928c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "restore-assistant" +name = "rsdb" version = "0.1.0" edition = "2021" diff --git a/README.md b/README.md index 4a6168a..d4af111 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Restore Assistant +# rsdb Assistente CLI/TUI em Rust para listar dumps em MinIO/S3, baixar arquivos para uma pasta local e restaurar um banco PostgreSQL com `DROP DATABASE` e recriação controlados por confirmação explícita. @@ -19,7 +19,7 @@ cargo build --release O binário ficará em: ```bash -target/release/restore-assistant +target/release/rsdb ``` ## Configuração @@ -82,25 +82,25 @@ Senhas nunca são exibidas. A senha do PostgreSQL é passada para `psql` e `pg_r Abrir a TUI: ```bash -restore-assistant +rsdb ``` Listar dumps remotos e locais: ```bash -restore-assistant list +rsdb list ``` Restaurar diretamente um dump local ou remoto, ainda com confirmação: ```bash -restore-assistant restore backup.sql.gz +rsdb restore backup.sql.gz ``` Validar configuração, pasta local, conexão S3 e ferramentas PostgreSQL: ```bash -restore-assistant config-check +rsdb config-check ``` ## Controles da TUI @@ -127,7 +127,7 @@ Antes da restauração, a TUI mostra o host, banco de destino e dump selecionado Logs técnicos são gravados em: ```bash -restore-assistant.log +rsdb.log ``` Erros exibidos na TUI ou CLI são resumidos para o usuário; detalhes técnicos ficam no log. diff --git a/src/config.rs b/src/config.rs index 0944634..be8133e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -49,7 +49,7 @@ impl Config { let mut file = merge_file_config(yaml, toml); if !yaml_path.exists() && !PathBuf::from("config.toml").exists() && !has_required_env() { - println!("Configuração inicial do restore-assistant"); + println!("Configuração inicial do rsdb"); println!("As respostas serão salvas em {}", yaml_path.display()); file = prompt_config()?; save_yaml(&yaml_path, &file)?; diff --git a/src/main.rs b/src/main.rs index 680f4f7..c580258 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ use crate::minio::MinioClient; use crate::postgres_restore::{confirm_in_terminal, restore_dump}; #[derive(Parser, Debug)] -#[command(name = "restore-assistant")] +#[command(name = "rsdb")] #[command(about = "Assistente para restaurar PostgreSQL a partir de dumps MinIO/S3")] struct Cli { #[command(subcommand)] @@ -51,14 +51,14 @@ async fn main() -> Result<()> { } fn init_logging() -> Result { - let file_appender = tracing_appender::rolling::never(".", "restore-assistant.log"); + let file_appender = tracing_appender::rolling::never(".", "rsdb.log"); let (non_blocking, guard) = tracing_appender::non_blocking(file_appender); tracing_subscriber::fmt() .with_writer(non_blocking) .with_ansi(false) .with_env_filter( tracing_subscriber::EnvFilter::try_from_default_env() - .unwrap_or_else(|_| "restore_assistant=info,restore_assistant=debug,info".into()), + .unwrap_or_else(|_| "rsdb=info".into()), ) .init(); Ok(guard) diff --git a/src/minio.rs b/src/minio.rs index 2456c2c..ff918cf 100644 --- a/src/minio.rs +++ b/src/minio.rs @@ -26,7 +26,7 @@ impl MinioClient { config.minio_secret_key.clone(), None, None, - "restore-assistant", + "rsdb", ); let shared_config = aws_config::defaults(BehaviorVersion::latest()) .endpoint_url(config.minio_endpoint.clone()) diff --git a/src/postgres_restore.rs b/src/postgres_restore.rs index ee0a39a..8d6ba5a 100644 --- a/src/postgres_restore.rs +++ b/src/postgres_restore.rs @@ -214,7 +214,7 @@ fn decompress_pg_restore_archive_to_temp( let file = std::fs::File::open(source) .with_context(|| format!("falha ao abrir {}", source.display()))?; let temp_path = std::env::temp_dir().join(format!( - "restore-assistant-{}-{}.tar", + "rsdb-{}-{}.tar", std::process::id(), chrono::Utc::now().timestamp_nanos_opt().unwrap_or_default() )); diff --git a/src/tui.rs b/src/tui.rs index 49b6886..39cf49c 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -256,7 +256,7 @@ impl App { .split(area); let title = format!( - "Restore Assistant | destino: {}:{} / {}", + "rsdb | destino: {}:{} / {}", self.config.postgres_host, self.config.postgres_port, self.config.postgres_database ); frame.render_widget(