feat: show backup time in message

incremental-backups
Jef Roosens 2023-06-07 21:15:15 +02:00 committed by Chewing_Bever
parent 9ce8199d5f
commit 90aa929b73
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 13 additions and 2 deletions

View File

@ -84,6 +84,7 @@ impl ServerProcess {
// We wait some time to (hopefully) ensure the save-all call has completed
std::thread::sleep(std::time::Duration::from_secs(10));
let start_time = chrono::offset::Local::now();
let res = self.create_backup_archive();
if res.is_ok() {
@ -93,10 +94,20 @@ impl ServerProcess {
// The server's save feature needs to be enabled again even if the archive failed to create
self.custom("save-on")?;
let duration = chrono::offset::Local::now() - start_time;
let duration_str = format!(
"{}m{}s",
duration.num_seconds() / 60,
duration.num_seconds() % 60
);
if res.is_ok() {
self.custom("say server backed up successfully")?;
self.custom(&format!("say server backed up in {}", duration_str))?;
} else {
self.custom("an error occured while backing up the server")?;
self.custom(&format!(
"an error occured after {} while backing up the server",
duration_str
))?;
}
res