Rename project to rsdb
This commit is contained in:
parent
91932c78b8
commit
c66a85b192
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,4 +2,4 @@
|
|||||||
/dumps
|
/dumps
|
||||||
/.env
|
/.env
|
||||||
/restore-assistant.log
|
/restore-assistant.log
|
||||||
|
/rsdb.log
|
||||||
|
|||||||
58
Cargo.lock
generated
58
Cargo.lock
generated
@ -2130,35 +2130,6 @@ version = "0.8.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
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]]
|
[[package]]
|
||||||
name = "rfc6979"
|
name = "rfc6979"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@ -2194,6 +2165,35 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"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]]
|
[[package]]
|
||||||
name = "rtoolbox"
|
name = "rtoolbox"
|
||||||
version = "0.0.5"
|
version = "0.0.5"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "restore-assistant"
|
name = "rsdb"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|||||||
14
README.md
14
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.
|
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:
|
O binário ficará em:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
target/release/restore-assistant
|
target/release/rsdb
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuração
|
## Configuração
|
||||||
@ -82,25 +82,25 @@ Senhas nunca são exibidas. A senha do PostgreSQL é passada para `psql` e `pg_r
|
|||||||
Abrir a TUI:
|
Abrir a TUI:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
restore-assistant
|
rsdb
|
||||||
```
|
```
|
||||||
|
|
||||||
Listar dumps remotos e locais:
|
Listar dumps remotos e locais:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
restore-assistant list
|
rsdb list
|
||||||
```
|
```
|
||||||
|
|
||||||
Restaurar diretamente um dump local ou remoto, ainda com confirmação:
|
Restaurar diretamente um dump local ou remoto, ainda com confirmação:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
restore-assistant restore backup.sql.gz
|
rsdb restore backup.sql.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
Validar configuração, pasta local, conexão S3 e ferramentas PostgreSQL:
|
Validar configuração, pasta local, conexão S3 e ferramentas PostgreSQL:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
restore-assistant config-check
|
rsdb config-check
|
||||||
```
|
```
|
||||||
|
|
||||||
## Controles da TUI
|
## 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:
|
Logs técnicos são gravados em:
|
||||||
|
|
||||||
```bash
|
```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.
|
Erros exibidos na TUI ou CLI são resumidos para o usuário; detalhes técnicos ficam no log.
|
||||||
|
|||||||
@ -49,7 +49,7 @@ impl Config {
|
|||||||
let mut file = merge_file_config(yaml, toml);
|
let mut file = merge_file_config(yaml, toml);
|
||||||
|
|
||||||
if !yaml_path.exists() && !PathBuf::from("config.toml").exists() && !has_required_env() {
|
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());
|
println!("As respostas serão salvas em {}", yaml_path.display());
|
||||||
file = prompt_config()?;
|
file = prompt_config()?;
|
||||||
save_yaml(&yaml_path, &file)?;
|
save_yaml(&yaml_path, &file)?;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use crate::minio::MinioClient;
|
|||||||
use crate::postgres_restore::{confirm_in_terminal, restore_dump};
|
use crate::postgres_restore::{confirm_in_terminal, restore_dump};
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(name = "restore-assistant")]
|
#[command(name = "rsdb")]
|
||||||
#[command(about = "Assistente para restaurar PostgreSQL a partir de dumps MinIO/S3")]
|
#[command(about = "Assistente para restaurar PostgreSQL a partir de dumps MinIO/S3")]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
@ -51,14 +51,14 @@ async fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init_logging() -> Result<tracing_appender::non_blocking::WorkerGuard> {
|
fn init_logging() -> Result<tracing_appender::non_blocking::WorkerGuard> {
|
||||||
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);
|
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
.with_writer(non_blocking)
|
.with_writer(non_blocking)
|
||||||
.with_ansi(false)
|
.with_ansi(false)
|
||||||
.with_env_filter(
|
.with_env_filter(
|
||||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
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();
|
.init();
|
||||||
Ok(guard)
|
Ok(guard)
|
||||||
|
|||||||
@ -26,7 +26,7 @@ impl MinioClient {
|
|||||||
config.minio_secret_key.clone(),
|
config.minio_secret_key.clone(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
"restore-assistant",
|
"rsdb",
|
||||||
);
|
);
|
||||||
let shared_config = aws_config::defaults(BehaviorVersion::latest())
|
let shared_config = aws_config::defaults(BehaviorVersion::latest())
|
||||||
.endpoint_url(config.minio_endpoint.clone())
|
.endpoint_url(config.minio_endpoint.clone())
|
||||||
|
|||||||
@ -214,7 +214,7 @@ fn decompress_pg_restore_archive_to_temp(
|
|||||||
let file = std::fs::File::open(source)
|
let file = std::fs::File::open(source)
|
||||||
.with_context(|| format!("falha ao abrir {}", source.display()))?;
|
.with_context(|| format!("falha ao abrir {}", source.display()))?;
|
||||||
let temp_path = std::env::temp_dir().join(format!(
|
let temp_path = std::env::temp_dir().join(format!(
|
||||||
"restore-assistant-{}-{}.tar",
|
"rsdb-{}-{}.tar",
|
||||||
std::process::id(),
|
std::process::id(),
|
||||||
chrono::Utc::now().timestamp_nanos_opt().unwrap_or_default()
|
chrono::Utc::now().timestamp_nanos_opt().unwrap_or_default()
|
||||||
));
|
));
|
||||||
|
|||||||
@ -256,7 +256,7 @@ impl App {
|
|||||||
.split(area);
|
.split(area);
|
||||||
|
|
||||||
let title = format!(
|
let title = format!(
|
||||||
"Restore Assistant | destino: {}:{} / {}",
|
"rsdb | destino: {}:{} / {}",
|
||||||
self.config.postgres_host, self.config.postgres_port, self.config.postgres_database
|
self.config.postgres_host, self.config.postgres_port, self.config.postgres_database
|
||||||
);
|
);
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user