1# @ohos.ability.BackupExtensionAbility (BackupExtensionAbility) 2 3The **BackupExtensionAbility** module provides extended backup and restore capabilities for applications. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> The APIs of this module can be used only in the stage model. 10 11## Modules to Import 12 13```ts 14import BackupExtension from '@ohos.ability.BackupExtensionAbility'; 15``` 16 17## BundleVersion 18 19Defines the version information required for data restore. You can determine the application data to be restored based on the version information. 20 21**System capability**: SystemCapability.FileManagement.StorageService.Backup 22 23| Name| Type | Mandatory| Description | 24| ---- | ------ | ---- | ---------------- | 25| code | number | Yes | Internal version number of the application. | 26| name | string | Yes | Version name of the application.| 27 28 29## BackupExtensionAbility.onBackup 30 31onBackup(): void; 32 33Called when data is being backed up. You need to implement extended data backup operations. 34 35**System capability**: SystemCapability.FileManagement.StorageService.Backup 36 37**Example** 38 39 ```ts 40 class BackupExt extends BackupExtension { 41 async onBackup() { 42 console.log('onBackup'); 43 } 44 } 45 ``` 46 47 48## BackupExtensionAbility.onRestore 49 50onRestore(bundleVersion: BundleVersion): void; 51 52Called when data is being restored. You need to implement extended data restore operations. 53 54**System capability**: SystemCapability.FileManagement.StorageService.Backup 55 56**Parameters** 57 58| Name | Type | Mandatory| Description | 59| ------------- | ------------------------------- | ---- | ------------------------------ | 60| bundleVersion | [BundleVersion](#bundleversion) | Yes | Version information of the application data to be restored.| 61 62**Example** 63 64 ```ts 65 class BackupExt extends BackupExtension { 66 async onRestore(bundleVersion : BundleVersion) { 67 console.log(`onRestore ok ${JSON.stringify(bundleVersion)}`); 68 } 69 } 70 ``` 71