Skip to content

Commit 010d084

Browse files
committed
vmm: Implement backup deletion and restore
1 parent b3d7cbd commit 010d084

File tree

11 files changed

+642
-77
lines changed

11 files changed

+642
-77
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

certbot/cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn load_config(config: &PathBuf) -> Result<CertBotConfig> {
121121
let renew_timeout = Duration::from_secs(config.renew_timeout);
122122
let bot_config = CertBotConfig::builder()
123123
.acme_url(config.acme_url)
124-
.cert_dir(workdir.backup_dir())
124+
.cert_dir(workdir.cert_backup_dir())
125125
.cert_file(workdir.cert_path())
126126
.key_file(workdir.key_path())
127127
.auto_create_account(true)

certbot/src/workdir.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ impl WorkDir {
2727
self.workdir.join("credentials.json")
2828
}
2929

30-
pub fn backup_dir(&self) -> PathBuf {
30+
pub fn cert_backup_dir(&self) -> PathBuf {
3131
self.workdir.join("backup")
3232
}
3333

34-
pub fn live_dir(&self) -> PathBuf {
34+
pub fn cert_live_dir(&self) -> PathBuf {
3535
self.workdir.join("live")
3636
}
3737

3838
pub fn cert_path(&self) -> PathBuf {
39-
self.live_dir().join("cert.pem")
39+
self.cert_live_dir().join("cert.pem")
4040
}
4141

4242
pub fn key_path(&self) -> PathBuf {
43-
self.live_dir().join("key.pem")
43+
self.cert_live_dir().join("key.pem")
4444
}
4545

4646
pub fn list_certs(&self) -> Result<Vec<PathBuf>> {
47-
crate::bot::list_certs(self.backup_dir())
47+
crate::bot::list_certs(self.cert_backup_dir())
4848
}
4949

5050
pub fn acme_account_uri(&self) -> Result<String> {
@@ -58,6 +58,6 @@ impl WorkDir {
5858
}
5959

6060
pub fn list_cert_public_keys(&self) -> Result<BTreeSet<Vec<u8>>> {
61-
crate::bot::list_cert_public_keys(self.backup_dir())
61+
crate::bot::list_cert_public_keys(self.cert_backup_dir())
6262
}
6363
}

gateway/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl CertbotConfig {
209209
let workdir = certbot::WorkDir::new(&self.workdir);
210210
certbot::CertBotConfig::builder()
211211
.auto_create_account(true)
212-
.cert_dir(workdir.backup_dir())
212+
.cert_dir(workdir.cert_backup_dir())
213213
.cert_file(workdir.cert_path())
214214
.key_file(workdir.key_path())
215215
.credentials_file(workdir.account_credentials_path())

vmm/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ hex_fmt.workspace = true
4444
lspci.workspace = true
4545
base64.workspace = true
4646
serde-human-bytes.workspace = true
47+
serde-duration.workspace = true
48+
chrono.workspace = true
4749

4850
[dev-dependencies]
4951
insta.workspace = true

vmm/rpc/proto/vmm_rpc.proto

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,39 @@ message GpuInfo {
226226

227227
message BackupDiskRequest {
228228
// vm id
229-
string id = 1;
229+
string vm_id = 1;
230230
// full or incremental
231231
string level = 2;
232232
}
233233

234234
message BackupInfo {
235-
// filename (e.g., FULL-1694222400-hd1.img)
236-
string filename = 1;
235+
// Group id
236+
string backup_id = 1;
237+
// id of the snapshot
238+
string snapshot_id = 2;
239+
// timestamp
240+
string timestamp = 3;
241+
// level: full or incremental
242+
string level = 4;
237243
// size of the backup in bytes
238-
uint64 size = 2;
244+
uint64 size = 5;
239245
}
240246

241247
message ListBackupsResponse {
242-
// list of backups
243248
repeated BackupInfo backups = 1;
244249
}
245250

251+
message DeleteBackupRequest {
252+
string vm_id = 1;
253+
string backup_id = 2;
254+
}
255+
256+
message RestoreBackupRequest {
257+
string vm_id = 1;
258+
string backup_id = 2;
259+
string snapshot_id = 3;
260+
}
261+
246262
// Service definition for dstack-vmm
247263
service Vmm {
248264
// RPC to create a VM
@@ -287,4 +303,10 @@ service Vmm {
287303

288304
// List backups for a VM
289305
rpc ListBackups(Id) returns (ListBackupsResponse);
306+
307+
// Delete a backup
308+
rpc DeleteBackup(DeleteBackupRequest) returns (google.protobuf.Empty);
309+
310+
// Restore a backup
311+
rpc RestoreBackup(RestoreBackupRequest) returns (google.protobuf.Empty);
290312
}

0 commit comments

Comments
 (0)