Skip to content

Setup

The use is so simple that you just have to start the class and use a function to start using the backuper.

const
const backup: Backup
backup
= new
new Backup({ backups, path, heartbeat, verbose }: BackupOptions): Backup

Create an new backup instance

Backup
({
BackupOptions.backups: string

Folder to save any backup

backups
: './backups', // Folder to save backups
BackupOptions.path: string

Folder or file to backup

path
: './', // Path to be backed up, can be a single file or a folder
BackupOptions.heartbeat: number

Heartbeat or interval in miliseconds to backup

heartbeat
: 30 * 60 * 1000, // Milliseconds between each backup, in this example it is 30 minutes.
BackupOptions.verbose?: VerboseOptions | null

Select whether you prefer to be notified of any process. Default: Only the start and end are notified

verbose
: {
VerboseOptions.start?: boolean

Records when a backup process starts

start
: true,
VerboseOptions.open_folder?: boolean

Logs when a folder to be backed up is opened

open_folder
: false,
VerboseOptions.open_file?: boolean

Logs when a file to be backed up is opened

open_file
: false,
VerboseOptions.end?: boolean

Records when a backup process ends

end
: true,
VerboseOptions.use?: boolean

Records when a backup is used

use
: false
}
});
const backup: Backup
backup
.
Backup.begin(): Promise<unknown>

Start the automatic backup system and create all necessary files and folders.

begin
(); // Create everything necessary and start the automatic backup process.

Following the above example, your files should look something like this:

  • package.json
  • Directorysrc
    • Directorybackups
      • index.json