Create a backup of a file before modification
Copies the current state of a file to the backup directory. If the file doesn't exist, records that fact for proper rollback handling.
Absolute path to the file to backup
Promise that resolves when backup is complete
Clean up backup directory after successful operation
Removes all temporary backup files and the backup directory. Should be called after all operations complete successfully.
Promise that resolves when cleanup is complete
Get statistics about current backup session
Object containing backup statistics
Initialize the backup manager by creating a temporary directory
Creates a unique temporary directory for storing file backups during the current operation. Must be called before any backup operations.
Promise that resolves when initialization is complete
Rollback all file changes by restoring from backups
Restores all backed-up files to their original state. Files that didn't exist before the operation are deleted. This operation is atomic - either all files are restored or none are.
Promise that resolves when rollback is complete
Manages file backups and rollback operations for MetadataSync
Creates temporary backups of all modified files during a push operation, allowing atomic rollback of all file changes if any error occurs.
FileBackupManager
Example