Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Demonstrator: New config management class (and some more stuff) #1850

Draft
wants to merge 70 commits into
base: dev
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
585e7fb
singleton structure
buhtz Aug 15, 2024
9c9e3d2
singleton ala Mars Landis
buhtz Aug 15, 2024
bcb9df5
x
buhtz Aug 15, 2024
7f02bb1
initial neo config inspection
buhtz Aug 19, 2024
289e572
x
buhtz Aug 19, 2024
43034b6
fixed manpage
buhtz Aug 19, 2024
53f2549
fix
buhtz Aug 19, 2024
4c4f9a6
add man page validation into release-howto [skip ci]
buhtz Aug 20, 2024
2d03f6c
typo [skip ci]
buhtz Aug 20, 2024
6a459ce
improve original create manapge script
buhtz Aug 20, 2024
cdff4a7
refactor create manpage script [skip ci]
buhtz Aug 20, 2024
5880b3e
Merge branch 'fix/manpage' into konfig
buhtz Aug 20, 2024
afde40f
x
buhtz Aug 20, 2024
4042671
x
buhtz Aug 21, 2024
be5fa06
linting man page
buhtz Aug 21, 2024
1bf383e
x
buhtz Aug 21, 2024
65457a0
before remove value-by-property-name
buhtz Aug 21, 2024
bbcaef1
x
buhtz Aug 21, 2024
1bbc30f
x
buhtz Aug 22, 2024
b2f3091
x#
buhtz Aug 22, 2024
3543ad3
x
buhtz Aug 22, 2024
a8ac3e3
x
buhtz Aug 23, 2024
52adb5a
Merge branch 'dev' into konfig
buhtz Aug 24, 2024
b499c6f
x
buhtz Aug 24, 2024
a83eed2
x [skip ci]
buhtz Aug 24, 2024
1c81c3a
Update common/konfig.py [skip ci]
buhtz Aug 29, 2024
9695116
Update common/konfig.py [skip
buhtz Aug 29, 2024
74ded33
Apply suggestions from code review [skip ci]
buhtz Aug 29, 2024
511a565
Update create-manpage-backintime-config.py [skip ci]
buhtz Aug 29, 2024
8b9221a
Merge branch 'dev' into konfig
buhtz Aug 31, 2024
2891c58
no interpolation
buhtz Aug 31, 2024
9da6ad5
extern file loading
buhtz Aug 31, 2024
8e9c6f4
minor fixes
buhtz Aug 31, 2024
bdd8ea2
[skip ci]
buhtz Aug 31, 2024
293bcf2
dirty
buhtz Aug 31, 2024
f98cf5c
x
buhtz Sep 1, 2024
e6373a6
next: excludeBySizeEnabled
buhtz Sep 2, 2024
be1918a
X
buhtz Sep 3, 2024
8c80328
x
buhtz Sep 5, 2024
d1a75a5
Merge branch 'dev' into konfig
buhtz Sep 22, 2024
51573f7
linting. replace pycodestyle by flake8
buhtz Sep 22, 2024
e5efdf8
some more steps [skip ci]
buhtz Sep 27, 2024
af92255
x
buhtz Sep 27, 2024
d23da6c
improved create script
buhtz Sep 27, 2024
6ed254c
properties finished [skip ci]
buhtz Sep 27, 2024
dbcbac1
Merge branch 'dev' into konfig
buhtz Oct 3, 2024
b66ce2b
x
buhtz Oct 3, 2024
b441789
Merge branch 'dev' into konfig
buhtz Oct 17, 2024
bb8d2d8
Merge branch 'dev' into konfig
buhtz Oct 19, 2024
8814b2f
Merge branch 'dev' into konfig
buhtz Oct 21, 2024
f61833d
Python 3.13 again after contacting Travis support
buhtz Oct 21, 2024
6511636
Merge branch 'dev' into konfig
buhtz Oct 30, 2024
2bd7212
Merge branch 'dev' into konfig
buhtz Nov 8, 2024
73ef542
Merge branch 'dev' into konfig
buhtz Nov 13, 2024
9465829
Merge branch 'dev' into konfig
buhtz Nov 17, 2024
48a71cd
Merge branch 'dev' into konfig
buhtz Nov 22, 2024
6b9db01
Merge branch 'dev' into konfig
buhtz Nov 23, 2024
446245e
Merge branch 'dev' into konfig
buhtz Nov 27, 2024
9682878
Merge branch 'dev' into konfig
buhtz Dec 3, 2024
fc4c84e
Merge branch 'dev' into konfig
buhtz Dec 7, 2024
10c389d
Merge branch 'dev' into konfig
buhtz Dec 17, 2024
99dfd63
Merge branch 'dev' into konfig
buhtz Dec 29, 2024
a2a8cfc
Merge branch 'dev' into konfig
buhtz Dec 31, 2024
40fce79
Merge branch 'dev' into konfig
buhtz Jan 5, 2025
8b7f804
Merge branch 'dev' into konfig
buhtz Jan 9, 2025
e43a3f0
Merge branch 'dev' into konfig
buhtz Jan 21, 2025
3717b19
Merge branch 'dev' into konfig
buhtz Jan 30, 2025
cc93c3a
Merge branch 'dev' into konfig
buhtz Feb 2, 2025
04971ef
Merge branch 'dev' into konfig
buhtz Feb 6, 2025
7371e6b
Merge branch 'dev' into konfig
buhtz Feb 8, 2025
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
Prev Previous commit
Next Next commit
x#
buhtz committed Aug 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b2f30914c49663277d99804ea264990a8738868e
16 changes: 16 additions & 0 deletions common/bitbase.py
Original file line number Diff line number Diff line change
@@ -10,3 +10,19 @@
# See issue #1734 and #1735
URL_ENCRYPT_TRANSITION = 'https://github.com/bit-team/backintime' \
'/blob/-/doc/ENCRYPT_TRANSITION.md'

SSH_CIPHERS = {
'default': _('Default'),
'aes128-ctr': 'AES128-CTR',
'aes192-ctr': 'AES192-CTR',
'aes256-ctr': 'AES256-CTR',
'arcfour256': 'ARCFOUR256',
'arcfour128': 'ARCFOUR128',
'aes128-cbc': 'AES128-CBC',
'3des-cbc': '3DES-CBC',
'blowfish-cbc': 'Blowfish-CBC',
'cast128-cbc': 'Cast128-CBC',
'aes192-cbc': 'AES192-CBC',
'aes256-cbc': 'AES256-CBC',
'arcfour': 'ARCFOUR'
}
18 changes: 2 additions & 16 deletions common/config.py
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
_('Warning')
except NameError:
_ = lambda val: val

import bitbase
import tools
import configfile
import logger
@@ -322,21 +322,7 @@ def __init__(self, config_path=None, data_path=None):
)
}

self.SSH_CIPHERS = {
'default': _('Default'),
'aes128-ctr': 'AES128-CTR',
'aes192-ctr': 'AES192-CTR',
'aes256-ctr': 'AES256-CTR',
'arcfour256': 'ARCFOUR256',
'arcfour128': 'ARCFOUR128',
'aes128-cbc': 'AES128-CBC',
'3des-cbc': '3DES-CBC',
'blowfish-cbc': 'Blowfish-CBC',
'cast128-cbc': 'Cast128-CBC',
'aes192-cbc': 'AES192-CBC',
'aes256-cbc': 'AES256-CBC',
'arcfour': 'ARCFOUR'
}
self.SSH_CIPHERS = bitbase.SSH_CIPHERS

def save(self):
self.setIntValue('config.version', self.CONFIG_VERSION)
111 changes: 106 additions & 5 deletions common/konfig.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
import os
import configparser
import inspect
import getpass
from typing import Union, Any
from pathlib import Path
from io import StringIO
@@ -21,9 +22,18 @@ class Konfig(metaclass=singleton.Singleton):

That class is a replacement for the `config.Config` class.
"""

DEFAULT_VALUES = {
}

class Profile:
DEFAULT_VALUES = {
'snapshots.ssh.port': 22,
'snapshots.ssh.cipher': 'default',
'snapshots.ssh.user': getpass.getuser(),
'snapshots.cipher': 'default',
'snapshots.ssh.private_key_file':
str(Path('~') / '.ssh' / 'id_rsa'),
}

def __init__(self, profile_id: int, config: Konfig):
@@ -55,7 +65,6 @@ def snapshots_path(self) -> str:

{
'values': 'absolute path',
'type': str,
}
"""
raise NotImplementedError('see original in Config class')
@@ -69,14 +78,13 @@ def ssh_snapshots_path(self) -> str:

{
'values': 'absolute or relative path',
'type': str,
}

"""
return self['snapshots.ssh.path']

@property
def ssh_host(self):
def ssh_host(self) -> str:
"""Remote host used for mode 'ssh' and 'ssh_encfs'.

{
@@ -90,7 +98,7 @@ def ssh_host(self, value: str) -> None:
self['snapshots.ssh.host'] = value

@property
def ssh_port(self) -> str:
def ssh_port(self) -> int:
"""SSH Port on remote host.

{
@@ -104,6 +112,99 @@ def ssh_port(self) -> str:
def ssh_port(self, value: int) -> None:
self['snapshots.ssh.port'] = value

@property
def ssh_user(self) -> str:
"""Remote SSH user.

{
'default': 'local users name',
'values': 'text',
}
"""
return self['snapshots.ssh.user']

@ssh_user.setter
def ssh_user(self, value: str) -> None:
self['snapshots.ssh.user'] = value

@property
def ssh_cipher(self) -> str:
"""Cipher that is used for encrypting the SSH tunnel. Depending on
the environment (network bandwidth, cpu and hdd performance) a
different cipher might be faster.

{
'values': 'default | aes192-cbc | aes256-cbc | aes128-ctr ' \
'| aes192-ctr | aes256-ctr | arcfour | arcfour256 ' \
'| arcfour128 | aes128-cbc | 3des-cbc | ' \
'blowfish-cbc | cast128-cbc',
}
"""
return self['snapshots.ssh.cipher']

@ssh_cipher.setter
def ssh_cipher(self, value: str) -> None:
self['snapshots.ssh.cipher'] = value

@property
def ssh_private_key_file(self) -> Path:
"""Private key file used for password-less authentication on remote
host.

{
'values': 'absolute path to private key file',
'type': 'str'
}

"""
raise NotImplementedError('see original in Config class')
path_string = self['snapshots.ssh.private_key_file']
return Path(path_string)

@property
def ssh_proxy_host(self) -> str:
"""Proxy host (or jump host) used to connect to remote host.

{
'values': 'IP or domain address',
}
"""
return self['snapshots.ssh.proxy_host']

@ssh_proxy_host.setter
def ssh_proxy_host(self, value: str) -> None:
self['snapshots.ssh.proxy_host'] = value

@property
def ssh_proxy_port(self) -> int:
"""Port of SSH proxy (jump) host used to connect to remote host.

{
'values': '0-65535',
'default': 22,
}
"""
return self['snapshots.ssh.proxy_port']

@ssh_proxy_port.setter
def ssh_proxy_port(self, value: int) -> None:
self['snapshots.ssh.proxy_port'] = value

@property
def ssh_proxy_user(self) -> str:
"""SSH user at proxy (jump) host.

{
'default': 'local users name',
'values': 'text',
}
"""
return self['snapshots.ssh.proxy_user']

@ssh_proxy_user.setter
def ssh_proxy_user(self, value: str) -> None:
self['snapshots.ssh.proxy_user'] = value


_DEFAULT_SECTION = '[bit]'

@@ -184,7 +285,7 @@ def hash_collision(self) -> int:
Do not change this.

{
'values': (0, 99999),
'values': '0-99999',
'default': 0,
}
"""
84 changes: 69 additions & 15 deletions common/man/C/backintime-config.1
Original file line number Diff line number Diff line change
@@ -16,18 +16,9 @@ Arguments don't need to be quoted. All characters are allowed except '='.
.PP
Run 'backintime check-config' to verify the configfile, create the snapshot folder and crontab entries.
.SH POSSIBLE KEYWORDS
.IP "\fIglobal.use_flock\fR" 6
.RS
Type: bool Allowed Values: true|false
.br
Prevent multiple snapshots (from different profiles or users) to be run at the same time.
.PP
Default: false
.RE

.IP "\fIglobal.hash_collision\fR" 6
.RS
Type: int Allowed Values: (0, 99999)
Type: int Allowed Values: 0-99999
.br
Internal value used to prevent hash collisions on mountpoints. Do not change this.
.PP
@@ -43,6 +34,15 @@ Language code (ISO 639) used to translate the user interface. If empty the opera

.RE

.IP "\fIglobal.use_flock\fR" 6
.RS
Type: bool Allowed Values: true|false
.br
Prevent multiple snapshots (from different profiles or users) to be run at the same time.
.PP
Default: false
.RE

.IP "\fIsnapshots.mode\fR" 6
.RS
Type: str Allowed Values: local|local_encfs|ssh|ssh_encfs
@@ -61,9 +61,18 @@ Where to save snapshots in mode 'local'. This path must contain a folderstructur

.RE

.IP "\fIsnapshots.ssh.path\fR" 6
.RS
Type: str Allowed Values: absolute or relative path
.br
Snapshot path on remote host. If the path is relative (no leading '/') it will start from remote Users homedir. An empty path will be replaced with './'.
.PP

.RE

.IP "\fIsnapshots.ssh.host\fR" 6
.RS
Type: _empty Allowed Values: IP or domain address
Type: str Allowed Values: IP or domain address
.br
Remote host used for mode 'ssh' and 'ssh_encfs'.
.PP
@@ -72,20 +81,65 @@ Remote host used for mode 'ssh' and 'ssh_encfs'.

.IP "\fIsnapshots.ssh.port\fR" 6
.RS
Type: str Allowed Values: 0-65535
Type: int Allowed Values: 0-65535
.br
SSH Port on remote host.
.PP
Default: 22
.RE

.IP "\fIsnapshots.ssh.path\fR" 6
.IP "\fIsnapshots.ssh.user\fR" 6
.RS
Type: str Allowed Values: absolute or relative path
Type: str Allowed Values: text
.br
Snapshot path on remote host. If the path is relative (no leading '/') it will start from remote Users homedir. An empty path will be replaced with './'.
Remote SSH user.
.PP
Default: local users name
.RE

.IP "\fIsnapshots.ssh.cipher\fR" 6
.RS
Type: str Allowed Values: default | aes192-cbc | aes256-cbc | aes128-ctr | aes192-ctr | aes256-ctr | arcfour | arcfour256 | arcfour128 | aes128-cbc | 3des-cbc | blowfish-cbc | cast128-cbc
.br
Cipher that is used for encrypting the SSH tunnel. Depending on the environment (network bandwidth, cpu and hdd performance) a different cipher might be faster.
.PP
Default: default
.RE

.IP "\fIsnapshots.ssh.private_key_file\fR" 6
.RS
Type: str Allowed Values: absolute path to private key file
.br
Private key file used for password-less authentication on remote host.
.PP
Default: ~/.ssh/id_rsa
.RE

.IP "\fIsnapshots.ssh.proxy_host\fR" 6
.RS
Type: str Allowed Values: IP or domain address
.br
Proxy host (or jump host) used to connect to remote host.
.PP

.RE

.IP "\fIsnapshots.ssh.proxy_port\fR" 6
.RS
Type: int Allowed Values: 0-65535
.br
Port of SSH proxy (jump) host used to connect to remote host.
.PP
Default: 22
.RE

.IP "\fIsnapshots.ssh.proxy_user\fR" 6
.RS
Type: str Allowed Values: text
.br
SSH user at proxy (jump) host.
.PP
Default: local users name
.RE

.SH SEE ALSO
Loading