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,
|
pub password: String,
|
||||||
#[arg(help = "help.arg.package-ids")]
|
#[arg(help = "help.arg.package-ids")]
|
||||||
pub ids: Vec<PackageId>,
|
pub ids: Vec<PackageId>,
|
||||||
|
#[arg(long, help = "help.arg.server-id")]
|
||||||
|
pub server_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[command(rename = "restore", display(display_none))]
|
// #[command(rename = "restore", display(display_none))]
|
||||||
@@ -50,13 +52,18 @@ pub async fn restore_packages_rpc(
|
|||||||
ids,
|
ids,
|
||||||
target_id,
|
target_id,
|
||||||
password,
|
password,
|
||||||
|
server_id,
|
||||||
}: RestorePackageParams,
|
}: RestorePackageParams,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let peek = ctx.db.peek().await;
|
let peek = ctx.db.peek().await;
|
||||||
let fs = target_id.load(&peek)?;
|
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(
|
let backup_guard = BackupMountGuard::mount(
|
||||||
TmpMountGuard::mount(&fs, ReadWrite).await?,
|
TmpMountGuard::mount(&fs, ReadWrite).await?,
|
||||||
&peek.as_public().as_server_info().as_id().de()?,
|
&server_id,
|
||||||
&password,
|
&password,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import type { BackupTargetId } from './BackupTargetId'
|
|||||||
import type { PackageId } from './PackageId'
|
import type { PackageId } from './PackageId'
|
||||||
|
|
||||||
export type RestorePackageParams = {
|
export type RestorePackageParams = {
|
||||||
ids: Array<PackageId>
|
|
||||||
targetId: BackupTargetId
|
targetId: BackupTargetId
|
||||||
password: string
|
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 ids = options.filter(({ checked }) => !!checked).map(({ id }) => id)
|
||||||
const loader = this.loader.open('Initializing').subscribe()
|
const loader = this.loader.open('Initializing').subscribe()
|
||||||
|
|
||||||
const { targetId, password } = this.context.data
|
const { targetId, serverId, password } = this.context.data
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.api.restorePackages({
|
await this.api.restorePackages({
|
||||||
ids,
|
ids,
|
||||||
targetId,
|
targetId,
|
||||||
password,
|
password,
|
||||||
|
serverId,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.context.$implicit.complete()
|
this.context.$implicit.complete()
|
||||||
|
|||||||
@@ -149,8 +149,8 @@ export class BackupsRecoverComponent {
|
|||||||
|
|
||||||
async restore(options: RecoverOption[]): Promise<void> {
|
async restore(options: RecoverOption[]): Promise<void> {
|
||||||
const ids = options.filter(({ checked }) => !!checked).map(({ id }) => id)
|
const ids = options.filter(({ checked }) => !!checked).map(({ id }) => id)
|
||||||
const { targetId, password } = this.context.data
|
const { targetId, serverId, password } = this.context.data
|
||||||
const params = { ids, targetId, password }
|
const params = { ids, targetId, password, serverId }
|
||||||
const loader = this.loader.open('Initializing').subscribe()
|
const loader = this.loader.open('Initializing').subscribe()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1242,6 +1242,7 @@ export namespace Mock {
|
|||||||
model: null,
|
model: null,
|
||||||
vendor: 'SSK',
|
vendor: 'SSK',
|
||||||
guid: null,
|
guid: null,
|
||||||
|
filesystem: null,
|
||||||
startOs: {
|
startOs: {
|
||||||
'1234-5678-9876-5432': {
|
'1234-5678-9876-5432': {
|
||||||
hostname: 'adjective-noun',
|
hostname: 'adjective-noun',
|
||||||
|
|||||||
Reference in New Issue
Block a user