backintime icon indicating copy to clipboard operation
backintime copied to clipboard

Config file in TOML format

Open buhtz opened this issue 11 months ago • 4 comments

Related to and ~~maybe~~ blocked by

  • #1850

  • Migrate the INI-like config file to TOML format.

  • Think about move the backups profiles as "data" into ~/.local/share/backintime.

This way it will be easier to read for human beings. That makes it easier to configure BIT on non-GUI systems.

buhtz avatar Dec 29 '24 12:12 buhtz

From @bjce in https://github.com/bit-team/backintime/issues/1594#issuecomment-3187702967 and https://github.com/bit-team/backintime/issues/1594#issuecomment-3187815317 .

Great I'll be happy to do that. 2 questions there if I may:

  1. Why the choice of TOML (and not YAML): is it because it is more resilient to failure to YAML?
  2. The TOML file would be a translation (maybe incomplete at the beginning at least) of the very nice config file if each backup profile (found at the root of each snapshot), alright? What do you think?

Here is an example of TOML config:

title = "myBITconfig"

# for local backups
[profile1]
name = "my_profile_name"

[profile1.source_path]
path = "/home/user"

[profile1.source_path]
path = "/media/user/my_HD_drive"

[profile1.schedule]
custom_time = [8,12,18,23]

[profile1.snapshot.exclude]
value01=".gvfs"
value02=".cache/*"
value03=".thumbnails*"
value04=".gvfs"
value06=".cache"
value07=".cargo"
value08=".config"
value09=".mozilla"
value10=".thunderbird"

[profile1.snapshots.smart_remove]
keep_all = 2
keep_one_per_day = 7
keep_one_per_month = 21
keep_one_per_week = 3

# for remote backups
[profile2]
name = "my_profile_name2"

[profile2.source_path]
path = "/home/user"

[profile2.source_path]
path = "/media/user/my_HD_drive"

[profile2.schedule]
custom_time = [8,12,18,23]

[profile2.snapshot.exclude]
value01=".gvfs"
value02=".cache/*"
value03=".thumbnails*"
value04=".gvfs"
value06=".cache"
value07=".cargo"
value08=".config"
value09=".mozilla"
value10=".thunderbird"

[profile2.snapshots.smart_remove]
keep_all = 2
keep_one_per_day = 7
keep_one_per_month = 21
keep_one_per_week = 3

[profile2.snapshots.ssh]
host = 192.168.1.1
path = "/media/myremote_HD"
port = 22
private_key_file = "/home/user/.ssh/id_ed25519"
user = "user"

buhtz avatar Aug 14 '25 10:08 buhtz

Thank you for your example.

  1. Why the choice of TOML (and not YAML): is it because it is more resilient to failure to YAML?

TOML is more human-friendly when it comes to reading and error tolerance. TOML is the default in the Python world.

TOML is INI-like so most users might be familiar with its style. YAML seems more exotic and familiar only to power users.

With a TOML file, we do not need a webinterface or TUI as requested in the past for headless servers.

  1. The TOML file would be a translation (maybe incomplete at the beginning at least) of the very nice config file if each backup profile (found at the root of each snapshot), alright?> What do you think?

I don't understand that question. The config file is located in $XDG_CONFIG_HOME (in most cases ~/.config/backintime/).

The TOML should be self-describing wereever it is possible. This is not the case in your TOML file example.

[profile1.source_path] path = "/home/user"

[profile1.source_path] path = "/media/user/my_HD_drive"

I would keep the "include" terminology.

[profile1.schedule] custom_time = [8,12,18,23]

No one will understand this without using the docu. But the scheduling options are the most complex and difficult, of course.

[profile1.snapshot.exclude] value01=".gvfs" value02=".cache/" value03=".thumbnails" value04=".gvfs" value06=".cache" value07=".cargo" value08=".config" value09=".mozilla" value10=".thunderbird"

This is what I mean. These are 10 variables. The exclude list should be one variable only. Or one for real files/dirs and one for regex patterns.

[profile1.snapshots.smart_remove] keep_all = 2 keep_one_per_day = 7 keep_one_per_month = 21 keep_one_per_week = 3

The same problem as in the scheduling section.

Regards, Christian

buhtz avatar Aug 14 '25 11:08 buhtz

I agree with everything. Sorry I meant dest_path (and not source_path

[profile1.dest_path]
path = "/media/user/my_HD_drive"
...

[profile2.dest_path]
path = "/media/user/my_HD_drive"

For the exclude in one bulk we can maybe just follow the rsync pattern which is like this if I am not mistaken:

# enter each pattern that you want to exclude with "--exclude=/the/patter/"
# ex: : --exclude=.gvfs --exclude=.cache/ --exclude=.thumbnails --exclude=.gvfs --exclude=.cache --exclude=.cargo --exclude=.config --exclude=.mozilla --exclude=.thunderbird
[profile2.snapshot.exclude]
patterns= "--exclude=.gvfs --exclude=.cache/ --exclude=.thumbnails --exclude=.gvfs --exclude=.cache --exclude=.cargo --exclude=.config --exclude=.mozilla --exclude=.thunderbird"

We can also comment the part with warning. Below is an updated proposition

title = "myBITconfig"

# for local backups
[profile1]
name = "my_profile_name"

[profile1.include]
# source path
path = "/home/user"

[profile1.dest_path]
path = "/media/user/my_HD_drive"

[profile1.schedule]
# Default parameter already set, changes are meant for advanced users only: 
# 24h format
custom_time = [8,12,18,23]

[profile1.snapshot.exclude]
# enter each pattern that you want to exclude with "--exclude=/the/patter/"
# ex: : --exclude=.gvfs --exclude=.cache/ --exclude=.thumbnails --exclude=.gvfs --exclude=.cache --exclude=.cargo --exclude=.config --exclude=.mozilla --exclude=.thunderbird
patterns= "--exclude=.gvfs --exclude=.cache/ --exclude=.thumbnails --exclude=.gvfs --exclude=.cache --exclude=.cargo --exclude=.config --exclude=.mozilla --exclude=.thunderbird"

[profile1.snapshots.smart_remove]
# Default parameter already set, changes are meant for advanced users only 
keep_all = 2
keep_one_per_day = 7
keep_one_per_month = 21
keep_one_per_week = 3

# for remote backups
[profile2]
name = "my_profile_name2"

[profile2.source_path]
# source path
path = "/home/user"

[profile2.dest_path]
path = "/media/user/my_HD_drive"


[profile2.snapshot.exclude]
# enter each pattern that you want to exclude with "--exclude=/the/patter/"
# ex: : --exclude=.gvfs --exclude=.cache/ --exclude=.thumbnails --exclude=.gvfs --exclude=.cache --exclude=.cargo --exclude=.config --exclude=.mozilla --exclude=.thunderbird
patterns= "--exclude=.gvfs --exclude=.cache/ --exclude=.thumbnails --exclude=.gvfs --exclude=.cache --exclude=.cargo --exclude=.config --exclude=.mozilla --exclude=.thunderbird"

[profile2.schedule]
# Default parameter already set, changes are meant for advanced users only 
# 24h format
custom_time = [8,12,18,23]

[profile2.snapshots.smart_remove]
# Default parameter already set, changes are meant for advanced users only 
keep_all = 2
keep_one_per_day = 7
keep_one_per_month = 21
keep_one_per_week = 3

[profile2.snapshots.ssh]
# Default parameter already set, changes are meant for advanced users only 
host = 192.168.1.1
path = "/media/myremote_HD"
port = 22
private_key_file = "/home/user/.ssh/id_ed25519"
user = "user"

Please tell me if you want me to do anything else actively

bjce avatar Aug 14 '25 11:08 bjce

Thank you for that example. I'll take it as an inspiration when taking this issue.

buhtz avatar Aug 14 '25 13:08 buhtz