feat: support restoring backups from a different server

This commit is contained in:
Aiden McClelland
2026-03-19 01:07:37 -06:00
parent e4b0f56fa7
commit 96dcd126db
5 changed files with 15 additions and 5 deletions

View File

@@ -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?;

View File

@@ -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
}

View File

@@ -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()

View File

@@ -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 {

View File

@@ -1242,6 +1242,7 @@ export namespace Mock {
model: null,
vendor: 'SSK',
guid: null,
filesystem: null,
startOs: {
'1234-5678-9876-5432': {
hostname: 'adjective-noun',