Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/borgitory/services/cloud_providers/storage/sftp_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class SFTPStorageConfig(CloudStorageConfig):
private_key: Optional[str] = None
remote_path: str = Field(..., min_length=1)
host_key_checking: bool = Field(default=True)
disable_server_side_checksums: bool = Field(
default=False,
description="Disable MD5/SHA1 hash commands on the remote server. Required for restricted SFTP servers (e.g. Ugreen NAS) that do not allow remote command execution.",
)

@field_validator("host")
@classmethod
Expand Down Expand Up @@ -147,6 +151,7 @@ async def upload_repository(
password=self._config.password,
private_key=self._config.private_key,
path_prefix=remote_path,
disable_hashcheck=self._config.disable_server_side_checksums,
):
if not progress_callback:
continue
Expand Down Expand Up @@ -279,11 +284,13 @@ def get_rclone_mapping(cls) -> RcloneMethodMapping:
"port": "port",
"password": "password",
"private_key": "private_key",
"disable_server_side_checksums": "disable_hashcheck",
},
Comment thread
mlapaglia marked this conversation as resolved.
required_params=["repository", "host", "username"],
optional_params={
"port": 22,
"path_prefix": "",
"disable_server_side_checksums": False,
},
Comment thread
mlapaglia marked this conversation as resolved.
)

Expand Down Expand Up @@ -341,6 +348,7 @@ async def sync_repository_to_sftp(
password: Optional[str] = None,
private_key: Optional[str] = None,
path_prefix: str = "",
disable_hashcheck: bool = False,
) -> AsyncGenerator[ProgressData, None]:
"""Sync a Borg repository to SFTP using Rclone with SFTP backend"""

Expand All @@ -359,6 +367,9 @@ async def sync_repository_to_sftp(
"--verbose",
]

if disable_hashcheck:
command.append("--sftp-disable-hashcheck")

try:
async with self._build_sftp_flags(
host, username, port, password, private_key
Expand Down Expand Up @@ -602,11 +613,13 @@ async def _test_sftp_write_permissions(
"port": "port",
"password": "password",
"private_key": "private_key",
"disable_server_side_checksums": "disable_hashcheck",
},
required_params=["repository", "host", "username"],
optional_params={
"port": 22,
"path_prefix": "",
"disable_server_side_checksums": False,
},
Comment thread
mlapaglia marked this conversation as resolved.
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@
</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-900 dark:text-gray-100">
Server-Side Checksums
</label>
<select name="provider_config[disable_server_side_checksums]"
class="select-modern mt-1">
<option value="false"
{% if not config or not config.disable_server_side_checksums %}selected{% endif %}>
Enabled (Recommended)
</option>
<option value="true"
{% if config and config.disable_server_side_checksums %}selected{% endif %}>
Disabled (for restricted SFTP servers, e.g. Ugreen NAS)
</option>
</select>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
Disable if your SFTP server does not allow remote command execution (md5sum/sha1sum).
</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-900 dark:text-gray-100">
Path Prefix (optional)
Expand Down
Loading
Loading