mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
appmgr: split bins update cargo.toml and .gitignore context appmgr: refactor error module appmgr: context begin new s9pk format appmgr: add fields to manifest appmgr: start action abstraction appmgr: volume abstraction appmgr: improved volumes appmgr: install wip appmgr: health daemon appmgr: health checks appmgr: wip config get appmgr: secret store wip appmgr: config rewritten appmgr: delete non-reusable code appmgr: wip appmgr: please the borrow-checker appmgr: technically runs now appmgr: cli appmgr: clean up cli appmgr: rpc-toolkit in action appmgr: wrap up config appmgr: account for updates during install appmgr: fix: #308 appmgr: impl Display for Version appmgr: cleanup appmgr: set dependents on install appmgr: dependency health checks
52 lines
1.5 KiB
Rust
52 lines
1.5 KiB
Rust
use anyhow::anyhow;
|
|
use patch_db::HasModel;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::action::ActionImplementation;
|
|
use crate::net::host::Hosts;
|
|
use crate::s9pk::manifest::PackageId;
|
|
use crate::util::Version;
|
|
use crate::volume::{Volume, VolumeId, Volumes};
|
|
use crate::{Error, ResultExt};
|
|
|
|
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
|
|
pub struct BackupActions {
|
|
pub create: ActionImplementation,
|
|
pub restore: ActionImplementation,
|
|
}
|
|
impl BackupActions {
|
|
pub async fn backup(
|
|
&self,
|
|
pkg_id: &PackageId,
|
|
pkg_version: &Version,
|
|
volumes: &Volumes,
|
|
hosts: &Hosts,
|
|
) -> Result<(), Error> {
|
|
let mut volumes = volumes.to_readonly();
|
|
volumes.insert(VolumeId::Backup, Volume::Backup { readonly: false });
|
|
self.create
|
|
.execute(pkg_id, pkg_version, &volumes, hosts, None::<()>, false)
|
|
.await?
|
|
.map_err(|e| anyhow!("{}", e.1))
|
|
.with_kind(crate::ErrorKind::Backup)?;
|
|
Ok(())
|
|
}
|
|
|
|
pub async fn restore(
|
|
&self,
|
|
pkg_id: &PackageId,
|
|
pkg_version: &Version,
|
|
volumes: &Volumes,
|
|
hosts: &Hosts,
|
|
) -> Result<(), Error> {
|
|
let mut volumes = volumes.clone();
|
|
volumes.insert(VolumeId::Backup, Volume::Backup { readonly: true });
|
|
self.restore
|
|
.execute(pkg_id, pkg_version, &volumes, hosts, None::<()>, false)
|
|
.await?
|
|
.map_err(|e| anyhow!("{}", e.1))
|
|
.with_kind(crate::ErrorKind::Restore)?;
|
|
Ok(())
|
|
}
|
|
}
|