Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,9 @@ pub enum BackupCommands {
Create {
/// Site ID
site_id: String,
/// Backup scope (full, database, files)
#[arg(long, default_value = "full")]
scope: String,
/// Backup description
#[arg(long)]
description: Option<String>,
Expand Down
18 changes: 15 additions & 3 deletions src/commands/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct PaginationQuery {
#[derive(Debug, Serialize)]
struct CreateBackupRequest {
r#type: String,
scope: String,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
}
Expand Down Expand Up @@ -51,14 +52,18 @@ pub fn list(
vec![
b["id"].as_str().unwrap_or("-").to_string(),
b["type"].as_str().unwrap_or("-").to_string(),
b["scope"].as_str().unwrap_or("-").to_string(),
b["status"].as_str().unwrap_or("-").to_string(),
format_option(&b["description"].as_str().map(String::from)),
format_option(&b["created_at"].as_str().map(String::from)),
]
})
.collect();

print_table(vec!["ID", "Type", "Status", "Description", "Created"], rows);
print_table(
vec!["ID", "Type", "Scope", "Status", "Description", "Created"],
rows,
);

if let Some((current, last, total)) = extract_pagination(&response) {
print_pagination(current, last, total);
Expand Down Expand Up @@ -88,6 +93,7 @@ pub fn show(
print_key_value(vec![
("ID", backup["id"].as_str().unwrap_or("-").to_string()),
("Type", backup["type"].as_str().unwrap_or("-").to_string()),
("Scope", backup["scope"].as_str().unwrap_or("-").to_string()),
(
"Status",
backup["status"].as_str().unwrap_or("-").to_string(),
Expand All @@ -97,8 +103,12 @@ pub fn show(
format_option(&backup["description"].as_str().map(String::from)),
),
(
"Snapshot ID",
format_option(&backup["snapshot_id"].as_str().map(String::from)),
"File Snapshot ID",
format_option(&backup["file_snapshot_id"].as_str().map(String::from)),
),
(
"Database Snapshot ID",
format_option(&backup["database_snapshot_id"].as_str().map(String::from)),
),
(
"Started At",
Expand All @@ -124,11 +134,13 @@ pub fn show(
pub fn create(
client: &ApiClient,
site_id: &str,
scope: &str,
description: Option<String>,
format: OutputFormat,
) -> Result<(), ApiError> {
let body = CreateBackupRequest {
r#type: "manual".to_string(),
scope: scope.to_string(),
description,
};

Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,9 @@ fn run_backup(command: BackupCommands, format: OutputFormat) -> Result<(), ApiEr
}
BackupCommands::Create {
site_id,
scope,
description,
} => backup::create(&client, &site_id, description, format),
} => backup::create(&client, &site_id, &scope, description, format),
}
}

Expand Down