mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Feature/manual db backup (#437)
Added: New button in manage server to manually create a backup of DB (Fixes Add on demand DB backup from Admin Dashboard #322)
This commit is contained in:
parent
66f40656dd
commit
3dbe7eec1f
@ -35,6 +35,10 @@ namespace API.Controllers
|
|||||||
_cacheService = cacheService;
|
_cacheService = cacheService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to Restart the server. Does not work, will shutdown the instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPost("restart")]
|
[HttpPost("restart")]
|
||||||
public ActionResult RestartServer()
|
public ActionResult RestartServer()
|
||||||
{
|
{
|
||||||
@ -44,6 +48,10 @@ namespace API.Controllers
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs an ad-hoc cleanup of Cache
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPost("clear-cache")]
|
[HttpPost("clear-cache")]
|
||||||
public ActionResult ClearCache()
|
public ActionResult ClearCache()
|
||||||
{
|
{
|
||||||
@ -53,6 +61,19 @@ namespace API.Controllers
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs an ad-hoc backup of the Database
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("backup-db")]
|
||||||
|
public ActionResult BackupDatabase()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("{UserName} is backing up database of server from admin dashboard", User.GetUsername());
|
||||||
|
_backupService.BackupDatabase();
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns non-sensitive information about the current system
|
/// Returns non-sensitive information about the current system
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -79,5 +100,6 @@ namespace API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<Company>kavitareader.com</Company>
|
<Company>kavitareader.com</Company>
|
||||||
<Product>Kavita</Product>
|
<Product>Kavita</Product>
|
||||||
<AssemblyVersion>0.4.3.1</AssemblyVersion>
|
<AssemblyVersion>0.4.3.2</AssemblyVersion>
|
||||||
<NeutralLanguage>en</NeutralLanguage>
|
<NeutralLanguage>en</NeutralLanguage>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -23,4 +23,8 @@ export class ServerService {
|
|||||||
clearCache() {
|
clearCache() {
|
||||||
return this.httpClient.post(this.baseUrl + 'server/clear-cache', {});
|
return this.httpClient.post(this.baseUrl + 'server/clear-cache', {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backupDatabase() {
|
||||||
|
return this.httpClient.post(this.baseUrl + 'server/backup-db', {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
Clear Cache
|
Clear Cache
|
||||||
</button>
|
</button>
|
||||||
|
<button class="btn btn-secondary mr-2" (click)="backupDB()" [disabled]="backupDBInProgress">
|
||||||
|
<ng-container *ngIf="backupDBInProgress">
|
||||||
|
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</ng-container>
|
||||||
|
Backup Database
|
||||||
|
</button>
|
||||||
<button class="btn btn-secondary" (click)="downloadService.downloadLogs()">
|
<button class="btn btn-secondary" (click)="downloadService.downloadLogs()">
|
||||||
Download Logs
|
Download Logs
|
||||||
</button>
|
</button>
|
||||||
|
@ -21,6 +21,7 @@ export class ManageSystemComponent implements OnInit {
|
|||||||
serverInfo!: ServerInfo;
|
serverInfo!: ServerInfo;
|
||||||
|
|
||||||
clearCacheInProgress: boolean = false;
|
clearCacheInProgress: boolean = false;
|
||||||
|
backupDBInProgress: boolean = false;
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService, private toastr: ToastrService,
|
constructor(private settingsService: SettingsService, private toastr: ToastrService,
|
||||||
private serverService: ServerService, public downloadService: DownloadService) { }
|
private serverService: ServerService, public downloadService: DownloadService) { }
|
||||||
@ -71,4 +72,12 @@ export class ManageSystemComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backupDB() {
|
||||||
|
this.backupDBInProgress = true;
|
||||||
|
this.serverService.backupDatabase().subscribe(res => {
|
||||||
|
this.backupDBInProgress = false;
|
||||||
|
this.toastr.success('Database has been backed up');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user