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
Use Cleanup.
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
Use GetStats.
Get statistics about current backup session
Object containing backup statistics
Use Initialize.
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
Stop tracking a file so rollback leaves it as it is now.
Used for files in an isolated directory whose records were already committed: restoring the old file would drop the primary keys and sync blocks of rows that stay in the database.
Absolute path of a file previously passed to backupFile
true when a backup was tracked for this file
Use Rollback.
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