Backup target host
BackupTargetHost
dataclass
¶
Describes a host containing backups. Can be source and destination.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the TargetHost |
target_config |
BackupTarget
|
The Config object describing this BackupTarget |
snapshot_dir |
BackupHostPath
|
Path to the snapshots of this target on this host |
connection |
Connection
|
Connection object to the host |
delete_snapshot ¶
Delete a snapshot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot
|
Snapshot
|
Snapshot to delete |
required |
subvolumes
|
list[BackupHostPath] | None
|
Subvolumes to delete. If None, all subvolumes are deleted |
None
|
Source code in b4_backup/main/backup_target_host.py
filter_subvolumes_by_backup_strategy ¶
Retrieve subvolumes that are marked as source only from a snapshot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subvolumes
|
Iterable[BackupHostPath]
|
Subvolumes to filter |
required |
backup_strategies
|
set[SubvolumeBackupStrategy]
|
Backup strategies to search for |
required |
Returns:
Type | Description |
---|---|
None
|
Generator of subvolumes |
Source code in b4_backup/main/backup_target_host.py
from_destination_host
classmethod
¶
Create an instance for a backup destination.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_name
|
str
|
Name of the target |
required |
target_config
|
BackupTarget
|
Target config |
required |
connection
|
Connection
|
Host connection |
required |
Returns:
Type | Description |
---|---|
DestinationBackupTargetHost
|
BackupHost instance |
Source code in b4_backup/main/backup_target_host.py
from_source_host
classmethod
¶
Create an instance for a backup source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_name
|
str
|
Name of the target |
required |
target_config
|
BackupTarget
|
Target config |
required |
connection
|
Connection
|
Host connection |
required |
Returns:
Type | Description |
---|---|
SourceBackupTargetHost
|
BackupHost instance |
Source code in b4_backup/main/backup_target_host.py
mount_point ¶
path ¶
Create a BackupHostPath instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
PurePath | str | None
|
Pathlike object. If None, the connection location will be used |
None
|
Returns:
Type | Description |
---|---|
BackupHostPath
|
BackupHostPath instance |
Source code in b4_backup/main/backup_target_host.py
remove_empty_dirs ¶
Recursively delete empty directories.
Returns:
Type | Description |
---|---|
bool
|
True if the top dir got deleted. |
Source code in b4_backup/main/backup_target_host.py
send_snapshot ¶
send_snapshot(
destination,
snapshot_name,
send_con=LocalConnection(PurePath()),
incremental=True,
)
Send a snapshot to the destination host.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination
|
BackupTargetHost
|
Destination host |
required |
snapshot_name
|
str
|
snapshot to transmit |
required |
send_con
|
LocalConnection
|
Optional connection from where to send from |
LocalConnection(PurePath())
|
incremental
|
bool
|
Only send the difference from the nearest snapshot already sent |
True
|
Source code in b4_backup/main/backup_target_host.py
snapshots ¶
source_subvolumes_from_snapshot ¶
Retrieve subvolumes that are marked as source only and ignore from a snapshot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot
|
Snapshot
|
Snapshot to retrieve the subvolumes from |
required |
Returns:
Type | Description |
---|---|
None
|
Generator of subvolumes |
Source code in b4_backup/main/backup_target_host.py
subvolumes ¶
Returns:
Type | Description |
---|---|
list[BackupHostPath]
|
A list of btrfs subvolumes. |
Source code in b4_backup/main/backup_target_host.py
DestinationBackupTargetHost
dataclass
¶
Bases: BackupTargetHost
Describes a destination host containing backups. An extention of the generic BackupHost.
SourceBackupTargetHost
dataclass
¶
Bases: BackupTargetHost
Describes a source host containing backups. An extention of the generic BackupHost.
create_snapshot ¶
Create a new snapshot for this target with the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot_name
|
str
|
Name of the snapshot. |
required |
Returns:
Type | Description |
---|---|
Snapshot
|
Instance of the newly created snapshot. |
Source code in b4_backup/main/backup_target_host.py
host_generator ¶
Creates a generator containing connected TargetHosts for source and destination.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_choice
|
ChoiceSelector
|
A ChoiceSelector list of targets to be used |
required |
backup_targets
|
dict[str, BackupTarget]
|
A dict containing all targets available |
required |
use_source
|
bool
|
If false, the source host will be omitted |
True
|
use_destination
|
bool
|
If false, the destination host will be omitted |
True
|
Returns:
Type | Description |
---|---|
None
|
A tuple containing source and destination TargetHosts |