rollback method
Implementation
Future<bool> rollback(String timestamp) async {
final currentBackupPath = p.join(Constants.backupDir, timestamp);
final dir = Directory(currentBackupPath);
if (!dir.existsSync()) {
throw BackupException('Backup "$timestamp" not found.');
}
try {
final files = dir.listSync(recursive: true).whereType<File>();
for (final file in files) {
final relativePath = p.relative(file.path, from: currentBackupPath);
final destination = File(relativePath);
destination.parent.createSync(recursive: true);
file.copySync(destination.path);
logger.info('Restored $relativePath');
}
logger.success('Rollback to "$timestamp" completed.');
return true;
} catch (e) {
throw BackupException('Rollback failed: $e');
}
}