imafaz / netback
lightweight library for backup and restore vpn servers
Requires
- php-64bit: >=7.0
- imafaz/easylog: ^1.0
- phpseclib/phpseclib: ^3.0
README
NetBack is a PHP library designed for backing up and restoring data from network devices and applications. It provides an easy-to-use interface for managing backups across various platforms, including IBSng, Mikrotik, and xui.
Features
- Backup and restore functionality for network devices.
- Support for multiple device types: IBSng, Mikrotik, and xui.
- Logging capabilities to track backup operations.
Requirements
- PHP 7.4 or higher
- Composer
- phpseclib3 library
- EasyLog library
Installation
You can install NetBack using Composer. Run the following command in your terminal:
composer require imafaz/netback
Usage
To use the NetBack library, you need to create instances of the classes corresponding to the devices you want to back up. Below are examples of how to use each class.
Examples
Example for IBSng
require __DIR__ . '/vendor/autoload.php'; use NetBack\IBSng; $ibsng = new IBSng('IBSngDevice', '192.168.1.1', 'username', 'password', 22); $ibsng->backup('/path/to/local/backup.sql');
Example for Mikrotik
require __DIR__ . '/vendor/autoload.php'; use NetBack\Mikrotik; $mikrotik = new Mikrotik('MikrotikDevice', '192.168.1.2', 'username', 'password', 22); $mikrotik->backup('backupName', '/path/to/local/backup.backup');
Example for xui
require __DIR__ . '/vendor/autoload.php'; use NetBack\xui; $xui = new xui('xuiDevice', '192.168.1.3', 'username', 'password', 22); $xui->backup('/path/to/local/xui.db');
Available Methods
IBSng
__construct
Description:
Initializes the IBSng object with connection parameters.
Signature:
$ibsng = new IBSng(string $name, string $ip, string $username, string $password, int $port);
Attributes:
backup
Description:
Performs a backup of the IBSng database.
Signature:
$ibsng->backup(string $localPath);
Attributes:
Mikrotik
__construct
Description:
Initializes the Mikrotik object with connection parameters.
Signature:
$mikrotik = new Mikrotik(string $name, string $ip, string $username, string $password, int $port);
Attributes:
backup
Description:
Creates a backup of the Mikrotik device.
Signature:
$mikrotik->backup(string $backupName, string $localPath);
Attributes:
xui
__construct
Description:
Initializes the xui object with connection parameters.
Signature:
$xui = new xui(string $name, string $ip, string $username, string $password, int $port);
Attributes:
backup
Description:
Downloads the xui database file.
Signature:
$xui->backup(string $localPath);
Attributes:
Todo
- add restore method
- add other devices support
License
This project is licensed under the MIT License. See the LICENSE file for details.