imafaz/netback 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

imafaz/netback

最新稳定版本:1.0.0

Composer 安装命令:

composer require imafaz/netback

包简介

lightweight library for backup and restore vpn servers

README 文档

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:

Attribute Description Type Required Default
$name Name of the IBSng device string Yes -
$ip IP address of the device string Yes -
$username Username for authentication string Yes -
$password Password for authentication string Yes -
$port Port for SSH connection int Yes 22

backup

Description:

Performs a backup of the IBSng database.

Signature:

$ibsng->backup(string $localPath);

Attributes:

Attribute Description Type Required Default
$localPath Path to save the backup file string Yes -

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:

Attribute Description Type Required Default
$name Name of the Mikrotik device string Yes -
$ip IP address of the device string Yes -
$username Username for authentication string Yes -
$password Password for authentication string Yes -
$port Port for SSH connection int Yes 22

backup

Description:

Creates a backup of the Mikrotik device.

Signature:

$mikrotik->backup(string $backupName, string $localPath);

Attributes:

Attribute Description Type Required Default
$backupName Name of the backup file string Yes -
$localPath Path to save the backup file string Yes -

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:

Attribute Description Type Required Default
$name Name of the xui device string Yes -
$ip IP address of the device string Yes -
$username Username for authentication string Yes -
$password Password for authentication string Yes -
$port Port for SSH connection int Yes 22

backup

Description:

Downloads the xui database file.

Signature:

$xui->backup(string $localPath);

Attributes:

Attribute Description Type Required Default
$localPath Path to save the database file string Yes -

Todo

  • add restore method
  • add other devices support

License

This project is licensed under the MIT License. See the LICENSE file for details.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-14