Compare commits

...

3 Commits

Author SHA1 Message Date
charlesgauthereau 4de2b81b33 chore(release): 1.1.2-rc.2 2026-02-16 09:00:26 +01:00
charlesgauthereau b06f9d8186 fix: failed backup 2026-02-16 09:00:18 +01:00
charlesgauthereau f5a2182723 fix: blocking for mysql database 2026-02-16 08:43:27 +01:00
5 changed files with 65 additions and 30 deletions
+1 -1
View File
@@ -22,5 +22,5 @@ keywords:
- self-hosted
- portabase
license: Apache-2.0
version: 1.1.2-rc.1
version: 1.1.2-rc.2
date-released: "2026-02-16"
Generated
+1 -1
View File
@@ -2851,7 +2851,7 @@ dependencies = [
[[package]]
name = "portabase-agent"
version = "1.1.1"
version = "1.1.2-rc.1"
dependencies = [
"aes",
"aes-gcm",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "portabase-agent"
version = "1.1.2-rc.1"
version = "1.1.2-rc.2"
edition = "2024"
[dependencies]
+14 -7
View File
@@ -1,19 +1,26 @@
use crate::services::config::DatabaseConfig;
use std::collections::HashMap;
use tokio::process::Command;
use tokio::time::{Duration, timeout};
pub async fn run(cfg: DatabaseConfig, env: HashMap<String, String>) -> anyhow::Result<bool> {
let output = Command::new("mysqladmin")
.arg("--host")
let mut cmd = Command::new("mysqladmin");
cmd.arg("--host")
.arg(cfg.host)
.arg("--port")
.arg(cfg.port.to_string())
.arg("--user")
.arg(cfg.username)
.arg("ping")
.envs(env)
.output()
.await?;
Ok(output.status.success())
.envs(env);
let result = timeout(Duration::from_secs(10), cmd.output()).await;
match result {
Ok(output) => {
let output = output?;
Ok(output.status.success())
}
Err(_) => Ok(false),
}
}
+48 -20
View File
@@ -69,7 +69,6 @@ impl BackupService {
return;
}
Ok(false) => {
match ctx
.api
.backup_create(
@@ -85,13 +84,27 @@ impl BackupService {
info!("Created temp directory {}", tmp_path.display());
match BackupService::run(db_cfg, &tmp_path).await {
Ok(mut result) => {
let backup_id = backup_created_result.unwrap().backup.id;
if result.status == "failed" {
error!("Backup failed early for {}", result.generated_id);
let service = BackupService { ctx: ctx.clone() };
let _ = service
.send_result(result, vec![], &backup_id)
.await;
return;
}
if let Some(backup_file) = result.backup_file.take() {
match compress_to_tar_gz_large(&backup_file).await {
Ok(compression_result) => {
result.backup_file =
Some(compression_result.compressed_path);
let service = BackupService { ctx: ctx.clone() };
let backup_id = backup_created_result.unwrap().backup.id;
match service
.upload(
result.clone(),
@@ -107,7 +120,7 @@ impl BackupService {
.send_result(
result,
upload_result,
&backup_id
&backup_id,
)
.await
{
@@ -147,7 +160,7 @@ impl BackupService {
}
Err(e) => error!("Backup creation failed: {}", e),
}
},
}
Err(e) => error!("An error occurred while checking lock : {}", e),
}
}
@@ -162,7 +175,16 @@ impl BackupService {
let generated_id = cfg.generated_id.clone();
let db_type = cfg.db_type.clone();
let reachable = db_instance.ping().await.unwrap_or(false);
let reachable = match db_instance.ping().await {
Ok(v) => v,
Err(e) => {
error!("Ping failed: {}", e);
return Err(e.into());
}
};
info!("Reachable: {}", reachable);
if !reachable {
return Ok(BackupResult {
@@ -276,7 +298,7 @@ impl BackupService {
}
}
};
match self.ctx.api.backup_upload_status(
self.ctx.edge_key.agent_id.clone(),
generated_id.clone(),
@@ -284,12 +306,12 @@ impl BackupService {
status,
remote_path,
total_size,
backup_id
backup_id,
).await {
Ok(_) => {
upload_result
},
Err(err)=> {
}
Err(err) => {
error!(
"backup_upload_status failed (generated_id={}, storage_id={}): {}",
generated_id, storage_id, err
@@ -355,17 +377,23 @@ impl BackupService {
"failed"
};
let file_size = upload_results
.iter()
.map(|r| r.total_size)
.try_fold((0u64, 0u64), |(sum, count), v| {
match v {
Some(size) => Ok((sum + size, count + 1)),
None => Err(()), // stop and return None
}
})
.ok()
.map(|(sum, count)| sum / count);
let file_size = if status == "failed" {
None
} else {
let mut sum = 0u64;
let mut count = 0u64;
for size in upload_results.iter().filter_map(|r| r.total_size) {
sum += size;
count += 1;
}
if count == 0 {
None
} else {
Some(sum / count)
}
};
match self
.ctx