Connection
Connection ¶
An abstract connection wrapper to execute commands on machines.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location
|
PurePath
|
Target directory or file. |
required |
Source code in b4_backup/main/connection.py
exec_prefix
abstractmethod
property
¶
Returns:
Type | Description |
---|---|
str
|
Prefix to run commands on the target using local commands. |
__enter__ ¶
__exit__ ¶
close
abstractmethod
¶
from_url
classmethod
¶
Parse the URL and return a fitting connection instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str | None
|
URL string to parse |
required |
Returns:
Type | Description |
---|---|
Connection | nullcontext
|
Connection instance |
Source code in b4_backup/main/connection.py
open
abstractmethod
¶
LocalConnection ¶
Bases: Connection
A connection wrapper to execute commands on the local machine.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location
|
PurePath
|
Target directory or file. |
required |
Source code in b4_backup/main/connection.py
exec_prefix
property
¶
Returns:
Type | Description |
---|---|
str
|
Prefix to run commands on the target using local commands. |
close ¶
open ¶
run_process ¶
Run a process without interaction and return the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command
|
list[str]
|
List of parameters |
required |
Returns: stdout of process.
Source code in b4_backup/main/connection.py
SSHConnection ¶
Bases: Connection
A connection wrapper to execute commands on remote machines via SSH.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
host
|
str
|
Hostname |
required |
location
|
PurePath
|
Target directory or file |
required |
port
|
int
|
Port |
22
|
user
|
str
|
Username |
'root'
|
password
|
str | None
|
Optional password. SSH key recommended. |
None
|
Source code in b4_backup/main/connection.py
exec_prefix
property
¶
Returns:
Type | Description |
---|---|
str
|
Prefix to run commands on the target using local commands. |
close ¶
Close the connection.
Source code in b4_backup/main/connection.py
open ¶
Open the connection to the target host.
Returns:
Type | Description |
---|---|
SSHConnection
|
Itself |
Source code in b4_backup/main/connection.py
run_process ¶
Run a process without interaction and return the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command
|
list[str]
|
List of parameters |
required |
Returns: stdout of process.
Source code in b4_backup/main/connection.py
URL
dataclass
¶
Contains an URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
protocol
|
str | None
|
protocol used. eg. ssh |
None
|
user
|
str
|
Username |
'root'
|
password
|
str | None
|
Password |
None
|
host
|
str | None
|
Hostname |
None
|
port
|
int
|
Port |
0
|
location
|
PurePath
|
Protocol specific location |
PurePath('/')
|
from_url
classmethod
¶
Create an instance by providing an URL string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
str
|
URL string |
required |
Returns:
Type | Description |
---|---|
URL
|
ParsedURL instance |