UrBackup Server API Client for Node.js

0.92.2 · active · verified Sun Apr 19

The `urbackup-server-api` module provides a Node.js interface for programmatic interaction with the UrBackup server's web API. It enables comprehensive management and monitoring of backup operations, including manipulating server and client settings, group management, task monitoring, initiating/stopping backups, accessing live logs, and fetching backup history. The current stable version is 0.92.2, indicating it is under active development and has not yet reached a 1.0.0 release. The project exhibits an iterative release cadence, with minor versions introducing new features and occasional method signature adjustments. Its primary differentiation lies in simplifying the automation and integration of UrBackup server administration directly within Node.js applications, making it valuable for server administrators and developers. Due to its pre-1.0 status, users should be aware that method signatures and functionality may change without major version bumps, necessitating a review of the CHANGELOG before updates.

Common errors

Warnings

Install

Imports

Quickstart

This example initializes the UrbackupServer client and demonstrates how to retrieve server activity, list clients by group, and identify clients with failed or missing backups.

import { UrbackupServer } from 'urbackup-server-api';

// When troubleshooting TSL connections with self-signed certificates, you may try to disable certificate validation.
// Keep in mind that it's strongly discouraged for production use.
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

const server = new UrbackupServer({
  url: process.env.URBACKUP_URL ?? 'http://127.0.0.1:55414',
  username: process.env.URBACKUP_USERNAME ?? 'admin',
  password: process.env.URBACKUP_PASSWORD ?? 'secretpassword',
});

(async () => {
  try {
    // Check if server is currently busy
    const activities = await server.getCurrentActivities();
    console.log(`Server Busy: ${activities.length > 0}`);

    // Get a list of clients in the 'prod' group
    const prodClients = await server.getGroupMembers({ groupName: 'prod' });
    console.log('Production Clients:', prodClients.map(c => c.name));

    // Get production clients with failed image backup
    const failedClients = await server.getFailedClients({ groupName: 'prod', includeFileBackups: false });
    console.log('Failed Image Backups in Prod:', failedClients.map(c => c.name));

    // Get all clients without both file and image backups
    const blankClients = await server.getBlankClients();
    console.log('Clients without any backups:', blankClients.map(c => c.name));
  } catch (error) {
    console.error('An error occurred:', error.message);
  }
})();

view raw JSON →