akeebabackup

NodeJS npm module for AkeebaBackup JSON APIs

AkeebaBackup module for NodeJS

This module lets you easily use the AkeebaBackup JSON APIs in node.js. AkeebaBackup (http://www.akeebabackup.com) is THE backup software for Joomla! As of version 0.1.0, it supports only the raw encryption, but in the future, if needed, the other encryption system supported by the apis will be added.

Using npm:

npm install akeebabackup

You can also clone this repository into your node_modules directory.

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    yoursite.backup();
    yoursite.on('completed', function(data){console.log('backup completed')});
} catch(e) {
    console.log(e);
}

Here you'll be able to see a list of methods available in the akeebabackup module, such as:

Trigger a new backup

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.backup(['profile_id']);  
    yoursite.backup(); 
    
    yoursite.on('started', function(data){
        console.log('backup started');
    });
    yoursite.on('step', function(data){
        console.log('backup has completed a step');
    });
    yoursite.on('completed', function(data){
        console.log('backup completed');
    });
} catch(e) {
    console.log(e);
}

Stops a running backup

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.backup(['profile_id']);  
    yoursite.backup(); 
    
    yoursite.on('stopped', function(){
        console.log('backup stopped');
    });
    
    yoursite.stopBackup();
 
} catch(e) {
    console.log(e);
}

Trigger a System Restore Point backup for an extension

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.srp('name', 'type', ['group']);  
    yoursite.srp('akeeba', 'component');
    
    yoursite.on('started', function(data){
        console.log('srp started');
    });
    yoursite.on('step', function(data){
        console.log('srp has completed a step');
    });
    yoursite.on('completed', function(data){
        console.log('srp completed');
    });
} catch(e) {
    console.log(e);
}

Completely removes a backup record from the database. Unlike deleteFiles, it will delete the files corresponding to the given backup record and the backup record itself. The Akeeba Backup component will not be aware that the specified backup record ever existed.

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.delete(id, callback) 
    yoursite.delete(42, function(result){
 
    });
} catch(e) {
    console.log(e);
}

Remove only the files corresponding to a given backup record, but not the backup record itself. The Akeeba Backup component will display this backup record marked as "obsolete"

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.deleteFiles(id, callback) 
    yoursite.deleteFiles(42, function(result){
 
    });
} catch(e) {
    console.log(e);
}

Download (step by step) a backup file to a file

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.download(id, file) 
    yoursite.download(42, 'yourbackup.jpa');
 
    yoursite.on('completed', function(){
        console.log('File saved');
    });
} catch(e) {
    console.log(e);
}

Download a file directly, without encryption and step by step download

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.downloadDirect(id, file) 
    yoursite.downloadDirect(42, 'yourbackup.jpa');
 
    yoursite.on('completed', function(){
        console.log('File saved');
    });
} catch(e) {
    console.log(e);
}

Gets detailed information about a specific backup record.

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.getBackupInfo(id, callback) 
    yoursite.getBackupInfo(42, function(data){
        console.log(data);
    });
} catch(e) {
    console.log(e);
}

Downloads The log file for a specific backup tag

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.getLog(tag, file) 
    yoursite.getLog('remote', 'log.txt');
 
    yoursite.on('completed', function(){
        console.log('Log saved');
    });
} catch(e) {
    console.log(e);
}

Returns a list of the backup profiles. The callback receives an array:

    [{id, name}]
var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.getProfiles(callback) 
    yoursite.getProfiles(function(data){
        console.log(data);
    });
} catch(e) {
    console.log(e);
}

Returns the version number of the API and the component. The callback receives an object:

    {api, component, date, edition, updateinfo}
var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.getVersion(callback) 
    yoursite.getVersion(function(data){
        console.log(data);
    });
} catch(e) {
    console.log(e);
}

Returns a (partial) list of the backup records known to the component. The records are presented in reverse order, i.e. the first record is the last backup attempt, whereas the last record is the earliest backup attempt known to the component.

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.listBackups(callback, start, limit) 
    yoursite.listBackups(function(data){
        console.log(data);
    }, 0, 50);
} catch(e) {
    console.log(e);
}

Triggers the entire akeeba update process

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    yoursite.update();
 
    yoursite.on('step', function(){
        console.log('step completed');
    });
    yoursite.on('completed', function(){
        console.log('update completed');
    });
} catch(e) {
    console.log(e);
}

Returns update status information, as returned by Live Update itself

var akeeba = require('akeebabackup');
var yoursite = new akeeba('http://www.example.com', 'yoursecretkey');
 
try {
    // yoursite.updateGetInformation(callback, force_fetch_new_data) 
    yoursite.updateGetInformation(function(data){
        console.log(data);
    }, true);
} catch(e) {
    console.log(e);
}