Skip to content

Backup Examples

Before starting

Below are several examples, in case you don’t know how to start the class you can see:

Get the registry

Get the log contents of your backups, they come from the index.json from where you set the folder to store your backups.

const backup: Backup
backup
.
Backup.registry: Record<string, string>

Get the registry of any backup

registry

Create a backup

Creates a backup, returns a Promise of the backup info

const backup: Backup
backup
.
Backup.create(): Promise<BackupInfo>

Creates a backup

@returnsReturn of the absolute backing path

create
()

Get a backup

Search a backup, returns a backup info or null

const backup: Backup
backup
.
Backup.info(search: string): BackupInfo | null

Get all the information from a backup

@paramsearch String to use as a search string

info
(/* SEARCH */) // The search can be the id (timesteamp) or name of the zip (for example: dpiitqkszwe4rri8).

Use a backup

Searchs a backup and uses it.

const backup: Backup
backup
.
Backup.use(id: string): Promise<true>

This can be either the timestamp or the zip name.

If the timestamp is given, the direct path will be obtained from the registry, otherwise it will be used by searching inside the registry for a timestamp that has that backup.

@paramid Timestamp or id to search

@returnsReturn true if everything went well, otherwise any errors will be logged and reissued.

use
(/* SEARCH */) // The search can be the id (timesteamp) or name of the zip (for example: dpiitqkszwe4rri8).