MCPcopy Create free account
hub / github.com/douglance/devsql / backup_table

Method backup_table

crates/ccql/src/sql/safety.rs:74–97  ·  view source on GitHub ↗

Create backups for tables that will be modified by a write operation

(&self, table_name: &str)

Source from the content-addressed store, hash-verified

72
73 /// Create backups for tables that will be modified by a write operation
74 pub fn backup_table(&self, table_name: &str) -> Result<Option<PathBuf>> {
75 if !self.backup_enabled {
76 return Ok(None);
77 }
78
79 let source_path = self.get_table_path(table_name)?;
80
81 if !source_path.exists() {
82 return Ok(None);
83 }
84
85 let backup_path = create_backup_path(&source_path);
86
87 fs::copy(&source_path, &backup_path).map_err(|e| {
88 Error::BackupFailed(format!(
89 "Failed to backup {} to {}: {}",
90 source_path.display(),
91 backup_path.display(),
92 e
93 ))
94 })?;
95
96 Ok(Some(backup_path))
97 }
98
99 /// Restore a table from its backup
100 #[allow(dead_code)]

Callers 1

executeMethod · 0.80

Calls 2

create_backup_pathFunction · 0.85
get_table_pathMethod · 0.80

Tested by

no test coverage detected