31

I've taken a backup of the file where my dconf database is stored (~/.config/dconf/user which is a binary file), and now I need to move some keys from the backup to the dconf in use.

How can I view the content of the backed up dconf without putting it "in place" and view it with for example dconf-editor?

0

2 Answers 2

37

To view the content of that file you could rename it - e.g. test - place it under ~/.config/dconf/ and then have dconf read/dump the settings from that file.
By default, dconf reads the user-db found in $XDG_CONFIG_HOME/dconf/:

A "user-db" line specifies a user database.
These databases are found in $XDG_CONFIG_HOME/dconf/. The name of the file to open in that directory is exactly as it is written in the profile. This file is expected to be in the binary dconf database format. Note that XDG_CONFIG_HOME cannot be set/modified per terminal or session, because then the writer and reader would be working on different DBs (the writer is started by DBus and cannot see that variable).

As a result, you would need a custom profile that points to that particular db file - e.g. user-db:test and then instruct dconf to dump the data (using the custom profile) via the DCONF_PROFILE environment variable:

cd
cp /path_to_backup_dconf/user ~/.config/dconf/test
printf %s\\n "user-db:test" > db_profile
DCONF_PROFILE=~/db_profile dconf dump / > old_settings

The result is a file (old_settings) containing the settings from your backed up dconf file, e.g.:

[org/gnome/desktop/interface]
font-name='DejaVu Sans Oblique 10'
document-font-name='DejaVu Sans Oblique 10'
gtk-im-module='gtk-im-context-simple'
clock-show-seconds=true
icon-theme='HighContrast'
monospace-font-name='DejaVu Sans Mono Oblique 10'

[org/gnome/desktop/input-sources]
sources=@a(ss) []
xkb-options=@as []

[org/gnome/desktop/wm/preferences]
num-workspaces=4
titlebar-font='DejaVu Sans Bold Oblique 10'

.......

You could then remove those files:

rm -f ~/db_profile ~/.config/dconf/test

and load the old settings into the current database:

dconf load / < old_settings

If you want to dump only specific settings just provide the path:

DCONF_PROFILE=~/db_profile dconf dump /org/gnome/desktop/wm/preferences/
[/]
num-workspaces=4
titlebar-font='DejaVu Sans Bold Oblique 10'

but note that for each path you should have a different file and when you load it you should specify the path accordingly:

dconf load /org/gnome/desktop/wm/preferences/ < old_wm_settings

Also note that, due to upstream changes, older dconf databases might contain paths, keys and values that are invalid in newer versions so full compatibility between db-files created by different versions of dconf isn't always guaranteed. In that case, you would have to inspect the resulting old_settings file and manually remove or edit the entries that are invalid before loading it into your current database.

4
  • 3
    I think reading is not a problem. Just set XDG_CONFIG_HOME to another directory. No profile magic needed. But writing to an arbitrary dconf file is hard and may make your profile trick necessary. Sep 5, 2019 at 5:27
  • I can confirm the profile changes aren't for reading/dumping needed.
    – jumpnett
    Dec 26, 2019 at 22:47
  • 3
    @TorstenBronger yupp, you're right, this works easily in a terminal: XDG_CONFIG_HOME=/some/backup/path/home/user/.config dconf-editor
    – Nicolas
    Jun 10, 2020 at 18:02
  • Why the heck are users supposed do this snapfu just to view the content? The "Dconf Editor" tool should have come with the ability to open a database file, or the dconf dump should have had the ability to take an input file path. Apr 13 at 7:08
-3

I think the first answer overly-complicated the matter, so let's try again, using /org/cinnamon/ as an example namespace to backup and restore:

To backup /org/cinnamon/:

From a terminal, run:

dconf dump /org/cinnamon/ > backup_of_my_cinnamon_settings

save the backup_of_my_cinnamon_settings file somewhere for later

To reset /org/cinnamon/ to defaults:

dconf reset -f /org/cinnamon/

Note, cinnamon may freeze or crash doing this

To restore all your settings for /org/cinnamon:

dconf load /org/cinnamon/ < backup_of_my_cinnamon_settings


The process would be the same for /org/gnome/terminal/, etc.

For best results, update app references when they are not running.

Thanks to Cinnamon docs for the tips.

1
  • 10
    I think you should try again: the question here is not how to backup and restore some settings but how to view (and maybe load) the settings from a saved binary file. Dec 26, 2018 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.