@@ -1601,6 +1601,70 @@ export type QueueTimeMetrics = {
16011601 getAvg : ( ) => number ;
16021602} ;
16031603
1604+ /**
1605+ * (Enterprise Edition only.) Options for creating a hot backup.
1606+ */
1607+ export type HotBackupOptions = {
1608+ /**
1609+ * If set to `true` and no global transaction lock can be acquired within the
1610+ * given timeout, a possibly inconsistent backup is taken.
1611+ *
1612+ * Default: `false`
1613+ */
1614+ allowInconsistent ?: boolean ;
1615+ /**
1616+ * (Enterprise Edition cluster only.) If set to `true` and no global
1617+ * transaction lock can be acquired within the given timeout, all running
1618+ * transactions are forcefully aborted to ensure that a consistent backup
1619+ * can be created.
1620+ *
1621+ * Default: `false`.
1622+ */
1623+ force ?: boolean ;
1624+ /**
1625+ * Label to appended to the backup's identifier.
1626+ *
1627+ * Default: If omitted or empty, a UUID will be generated.
1628+ */
1629+ label ?: string ;
1630+ /**
1631+ * Time in seconds that the operation will attempt to get a consistent
1632+ * snapshot.
1633+ *
1634+ * Default: `120`.
1635+ */
1636+ timeout ?: number ;
1637+ } ;
1638+
1639+ /**
1640+ * (Enterprise Edition only.) Result of a hot backup.
1641+ */
1642+ export type HotBackupResult = {
1643+ id : string ;
1644+ potentiallyInconsistent : boolean ;
1645+ sizeInBytes : number ;
1646+ datetime : string ;
1647+ nrDBServers : number ;
1648+ nrFiles : number ;
1649+ } ;
1650+
1651+ /**
1652+ * (Enterprise Edition only.) List of known hot backups.
1653+ */
1654+ export type HotBackupList = {
1655+ server : string ;
1656+ list : Record <
1657+ string ,
1658+ HotBackupResult & {
1659+ version : string ;
1660+ keys : any [ ] ;
1661+ available : boolean ;
1662+ nrPiecesPresent : number ;
1663+ countIncludesFilesOnly : boolean ;
1664+ }
1665+ > ;
1666+ } ;
1667+
16041668/**
16051669 * An object representing a single ArangoDB database. All arangojs collections,
16061670 * cursors, analyzers and so on are linked to a `Database` object.
@@ -2857,7 +2921,6 @@ export class Database {
28572921 }
28582922 //#endregion
28592923
2860- //#region users
28612924 /**
28622925 * Fetches all ArangoDB users visible to the authenticated user and returns
28632926 * an array of user objects.
@@ -5569,4 +5632,102 @@ export class Database {
55695632 ) ;
55705633 }
55715634 //#endregion
5635+ //#region hot backups
5636+ /**
5637+ * (Enterprise Edition only.) Creates a hot backup of the entire ArangoDB
5638+ * deployment including all databases, collections, etc.
5639+ *
5640+ * Returns an object describing the backup result.
5641+ *
5642+ * @param options - Options for creating the backup.
5643+ *
5644+ * @example
5645+ * ```js
5646+ * const info = await db.createHotBackup();
5647+ * // a hot backup has been created
5648+ * ```
5649+ */
5650+ createHotBackup ( options : HotBackupOptions = { } ) : Promise < HotBackupResult > {
5651+ return this . request (
5652+ {
5653+ method : "POST" ,
5654+ path : "/_admin/backup/create" ,
5655+ body : options ,
5656+ } ,
5657+ ( res ) => res . body . result
5658+ ) ;
5659+ }
5660+
5661+ /**
5662+ * (Enterprise Edition only.) Retrieves a list of all locally found hot
5663+ * backups.
5664+ *
5665+ * @param id - If specified, only the backup with the given ID will be
5666+ * returned.
5667+ *
5668+ * @example
5669+ * ```js
5670+ * const backups = await db.listHotBackups();
5671+ * for (const backup of backups) {
5672+ * console.log(backup.id);
5673+ * }
5674+ * ```
5675+ */
5676+ listHotBackups ( id ?: string | string [ ] ) : Promise < HotBackupList > {
5677+ return this . request (
5678+ {
5679+ method : "POST" ,
5680+ path : "/_admin/backup/list" ,
5681+ body : id ? { id } : undefined ,
5682+ } ,
5683+ ( res ) => res . body . result
5684+ ) ;
5685+ }
5686+
5687+ /**
5688+ * (Enteprise Edition only.) Restores a consistent local hot backup.
5689+ *
5690+ * Returns the directory path of the restored backup.
5691+ *
5692+ * @param id - The ID of the backup to restore.
5693+ *
5694+ * @example
5695+ * ```js
5696+ * await db.restoreHotBackup("2023-09-19T15.38.21Z_example");
5697+ * // the backup has been restored
5698+ * ```
5699+ */
5700+ restoreHotBackup ( id : string ) : Promise < string > {
5701+ return this . request (
5702+ {
5703+ method : "POST" ,
5704+ path : "/_admin/backup/restore" ,
5705+ body : { id } ,
5706+ } ,
5707+ ( res ) => res . body . result . previous
5708+ ) ;
5709+ }
5710+
5711+ /**
5712+ * (Enterprise Edition only.) Deletes a local hot backup.
5713+ *
5714+ * @param id - The ID of the backup to delete.
5715+ *
5716+ * @example
5717+ * ```js
5718+ * await db.deleteHotBackup("2023-09-19T15.38.21Z_example");
5719+ * // the backup has been deleted
5720+ * ```
5721+ */
5722+ deleteHotBackup ( id : string ) : Promise < void > {
5723+ return this . request (
5724+ {
5725+ method : "POST" ,
5726+ path : "/_admin/backup/delete" ,
5727+ body : { id } ,
5728+ } ,
5729+ ( ) => undefined
5730+ ) ;
5731+ }
5732+ //#endregion
55725733}
0 commit comments