mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
feat: support restoring backups from a different server
This commit is contained in:
@@ -40,6 +40,8 @@ pub struct RestorePackageParams {
|
||||
pub password: String,
|
||||
#[arg(help = "help.arg.package-ids")]
|
||||
pub ids: Vec<PackageId>,
|
||||
#[arg(long, help = "help.arg.server-id")]
|
||||
pub server_id: Option<String>,
|
||||
}
|
||||
|
||||
// #[command(rename = "restore", display(display_none))]
|
||||
@@ -50,13 +52,18 @@ pub async fn restore_packages_rpc(
|
||||
ids,
|
||||
target_id,
|
||||
password,
|
||||
server_id,
|
||||
}: RestorePackageParams,
|
||||
) -> Result<(), Error> {
|
||||
let peek = ctx.db.peek().await;
|
||||
let fs = target_id.load(&peek)?;
|
||||
let server_id = match server_id {
|
||||
Some(id) => id,
|
||||
None => peek.as_public().as_server_info().as_id().de()?,
|
||||
};
|
||||
let backup_guard = BackupMountGuard::mount(
|
||||
TmpMountGuard::mount(&fs, ReadWrite).await?,
|
||||
&peek.as_public().as_server_info().as_id().de()?,
|
||||
&server_id,
|
||||
&password,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -3,7 +3,8 @@ import type { BackupTargetId } from './BackupTargetId'
|
||||
import type { PackageId } from './PackageId'
|
||||
|
||||
export type RestorePackageParams = {
|
||||
ids: Array<PackageId>
|
||||
targetId: BackupTargetId
|
||||
password: string
|
||||
ids: Array<PackageId>
|
||||
serverId: string | null
|
||||
}
|
||||
|
||||
@@ -115,13 +115,14 @@ export class BackupsRecoverModal {
|
||||
const ids = options.filter(({ checked }) => !!checked).map(({ id }) => id)
|
||||
const loader = this.loader.open('Initializing').subscribe()
|
||||
|
||||
const { targetId, password } = this.context.data
|
||||
const { targetId, serverId, password } = this.context.data
|
||||
|
||||
try {
|
||||
await this.api.restorePackages({
|
||||
ids,
|
||||
targetId,
|
||||
password,
|
||||
serverId,
|
||||
})
|
||||
|
||||
this.context.$implicit.complete()
|
||||
|
||||
@@ -149,8 +149,8 @@ export class BackupsRecoverComponent {
|
||||
|
||||
async restore(options: RecoverOption[]): Promise<void> {
|
||||
const ids = options.filter(({ checked }) => !!checked).map(({ id }) => id)
|
||||
const { targetId, password } = this.context.data
|
||||
const params = { ids, targetId, password }
|
||||
const { targetId, serverId, password } = this.context.data
|
||||
const params = { ids, targetId, password, serverId }
|
||||
const loader = this.loader.open('Initializing').subscribe()
|
||||
|
||||
try {
|
||||
|
||||
@@ -1242,6 +1242,7 @@ export namespace Mock {
|
||||
model: null,
|
||||
vendor: 'SSK',
|
||||
guid: null,
|
||||
filesystem: null,
|
||||
startOs: {
|
||||
'1234-5678-9876-5432': {
|
||||
hostname: 'adjective-noun',
|
||||
|
||||
Reference in New Issue
Block a user