node-xen-backup
node-xen-backup is a Node.js module that uses xen-api to take a snapshot of a Xenserver VM and export to a file for backup. The module includes a cli to execute direct on bash.
You can contribute
It is a free software and its use is free for everyone, but if you want to contribute anyway, please submit a donation.
Support
- Node.js (tested on >= 7.x)
Installation
Installing global for cli usage
> npm install -g node-xen-backup
Installing as node module
> npm install node-xen-backup
const XenBackup =
Cli
Getting help
> xen-backup --help # Usage: xen-backup [options] # Options: # # -V, --version output the version number # -H, --host [host] IP or hostname from Xenserver. Default: localhost. # -P, --port [port] TCP port from Xenserver. Default: 80. # -u, --username [username] Username to login in Xenserver. # -p, --password <password> Password to login in Xenserver. # -f, --filename <filename> Path to target file of exported snapshot. # -t, --type <type> Type of object to export. <vm|vdi> default vm. # -v, --vm <vm> VM name label or uuid to backup. # -h, --help output usage information
Creating a backup to a VM
# Backup command > xen-backup -H 192.168.1.1 -P 80 -u root -p password -f /backup/VMLinux.xva -v VMLinux# Normal output - Searching
API
Creating a backup
Example creating a backup using as Node.js module. This is very much like procedure used in cli.
// [another requires...] const XenBackup = const connOptions = username: 'root' password: 'password' host: '192.168.1.1' port: 80 sessionId: nullconst destFileName = "/backup/filename.xva" // First sets connecion options.XenBackup// Login in xenserver xen-api.XenBackup { if programtype === 'vm' XenBackup if programtype === 'vdi' XenBackup if programtype !== 'vdi' && programtype !== 'mv' return } { let sufix = null if programtype === 'vm' sufix = `/export?session_id=&use_compression=true&uuid=` if programtype === 'vdi' sufix = `/export_raw_vdi?session_id=&format=vhd&vdi=` let req = request if programtype === 'vdi' req else req }