add database backup with admin commands
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
ece817c562
commit
fa942aedd7
8 changed files with 144 additions and 2 deletions
|
@ -436,6 +436,12 @@ enum ServerCommand {
|
|||
ClearServiceCaches {
|
||||
amount: u32,
|
||||
},
|
||||
|
||||
/// - Backup the database
|
||||
BackupDatabase,
|
||||
|
||||
/// - List database backups
|
||||
ListBackups,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -1866,6 +1872,27 @@ impl Service {
|
|||
|
||||
RoomMessageEventContent::text_plain("Done.")
|
||||
},
|
||||
ServerCommand::ListBackups => {
|
||||
let result = services().globals.db.backup_list()?;
|
||||
|
||||
RoomMessageEventContent::text_plain(result)
|
||||
},
|
||||
ServerCommand::BackupDatabase => {
|
||||
let mut result = tokio::task::spawn_blocking(move || {
|
||||
match services().globals.db.backup() {
|
||||
Ok(_) => String::new(),
|
||||
Err(e) => (*e).to_string(),
|
||||
}
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
if result.is_empty() {
|
||||
result = services().globals.db.backup_list()?;
|
||||
}
|
||||
|
||||
RoomMessageEventContent::text_plain(&result)
|
||||
},
|
||||
},
|
||||
AdminCommand::Debug(command) => match command {
|
||||
DebugCommand::GetAuthChain {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue