Skip to content

Commit 5b60e19

Browse files
committed
vmm: Implement backup deletion and restore
1 parent b1df1aa commit 5b60e19

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
@@ -210,7 +210,7 @@ impl CertbotConfig {
210210
let workdir = certbot::WorkDir::new(&self.workdir);
211211
certbot::CertBotConfig::builder()
212212
.auto_create_account(true)
213-
.cert_dir(workdir.backup_dir())
213+
.cert_dir(workdir.cert_backup_dir())
214214
.cert_file(workdir.cert_path())
215215
.key_file(workdir.key_path())
216216
.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
@@ -225,23 +225,39 @@ message GpuInfo {
225225

226226
message BackupDiskRequest {
227227
// vm id
228-
string id = 1;
228+
string vm_id = 1;
229229
// full or incremental
230230
string level = 2;
231231
}
232232

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

240246
message ListBackupsResponse {
241-
// list of backups
242247
repeated BackupInfo backups = 1;
243248
}
244249

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

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

0 commit comments

Comments
 (0)