tuwunel_admin/server/
backup_database.rs1use std::sync::Arc;
2
3use tuwunel_core::Result;
4
5use crate::admin_command;
6
7#[admin_command]
8pub(super) async fn backup_database(&self) -> Result {
9 let db = Arc::clone(&self.services.db);
10 let result = self
11 .services
12 .server
13 .runtime()
14 .spawn_blocking(move || match db.engine.backup() {
15 | Ok(()) => "Done".to_owned(),
16 | Err(e) => format!("Failed: {e}"),
17 })
18 .await?;
19
20 let count = self.services.db.engine.backup_count()?;
21 write!(self, "{result}. Currently have {count} backups.").await
22}