Added ability to upload backups via FTP

This commit is contained in:
Pinga 2025-02-03 19:00:48 +02:00
parent e3f5d9f94e
commit 8e943ce1c8
3 changed files with 35 additions and 6 deletions

View file

@ -1,5 +1,15 @@
{
"storageType": "sftp",
"ftp": {
"host": "your_sftp_host",
"username": "your_username",
"password": "your_password",
"port": 21,
"basePath": "/",
"passive": true,
"ssl": false,
"timeout": 30
},
"sftp": {
"host": "your_sftp_host",
"username": "your_username",

View file

@ -4,6 +4,8 @@ require __DIR__ . '/vendor/autoload.php';
require_once 'helpers.php';
use League\Flysystem\Filesystem;
use League\Flysystem\Ftp\FtpAdapter;
use League\Flysystem\Ftp\FtpConnectionOptions;
use League\Flysystem\PhpseclibV3\SftpConnectionProvider;
use League\Flysystem\PhpseclibV3\SftpAdapter;
use League\Flysystem\UnixVisibility\PortableVisibilityConverter;
@ -63,6 +65,22 @@ switch ($storageType) {
$adapter = new SftpAdapter($sftpProvider, $sftpSettings['basePath'], $visibilityConverter);
break;
case 'ftp':
$ftpSettings = $config['ftp'];
$connectionOptions = FtpConnectionOptions::fromArray([
'host' => $ftpSettings['host'],
'username' => $ftpSettings['username'],
'password' => $ftpSettings['password'],
'port' => $ftpSettings['port'] ?? 21,
'root' => $ftpSettings['basePath'] ?? '/',
'passive' => $ftpSettings['passive'] ?? true,
'ssl' => $ftpSettings['ssl'] ?? false,
'timeout' => $ftpSettings['timeout'] ?? 30,
]);
$adapter = new FtpAdapter($connectionOptions);
break;
case 'dropbox':
$dropboxSettings = $config['dropbox'];
$client = new \Spatie\Dropbox\Client($dropboxSettings['accessToken']);

View file

@ -1,14 +1,15 @@
{
"require": {
"badcow/dns": "^4.2",
"phpseclib/phpseclib": "^3.0",
"phpbu/phpbu": "^6.0",
"setbased/php-audit": "^1.9",
"monolog/monolog": "^3.7",
"badcow/dns": "^4.3",
"phpseclib/phpseclib": "^3.0.43",
"phpbu/phpbu": "^6.0.29",
"setbased/php-audit": "^1.10.0",
"monolog/monolog": "^3.8.1",
"league/flysystem": "^3.28",
"league/flysystem-sftp-v3": "^3.28",
"peppeocchi/php-cron-scheduler": "^4.0",
"predis/predis": "^2.2",
"guzzlehttp/guzzle": "^7.9"
"guzzlehttp/guzzle": "^7.9",
"league/flysystem-ftp": "^3.29"
}
}