util.sftp¶
Wrapper around Paramiko SFTP functionality and related exceptions.
Module Contents¶
- exception util.sftp.SftpError[source]¶
Bases:
ExceptionCustom exception for any SFTP-related failures.
- class util.sftp.SftpClient(overrides=None)[source]¶
Wrapper around Paramiko SFTP functionality.
If instantiated without overrides, reads settings from BackupOptions(pk=1). Optionally, an overrides dict can supply:
host, port, user, auth_method, password, private_key, key_passphrase, local_storage, remote_directory.
- Parameters:
overrides (dict[str, Any] | None)
- test_connection()[source]¶
Attempt an SFTP connection with the current settings.
- Raises:
SftpError – If no auth_method, authentication fails, or any SSH error.
- Return type:
None
- upload_file(local_filepath, remote_path)[source]¶
Upload a single local file to the remote_path via SFTP.
- Parameters:
local_filepath (pathlib.Path) – Path to the local file to upload.
remote_path (str) – Full remote path (including filename) at the server.
- Raises:
SftpError – If no auth_method, local file missing, or any SSH/SFTP error.
- Return type:
None