Application setting backup example commit

This commit is contained in:
Brian Zalewski 2023-12-09 09:17:07 +00:00
parent 9d0956f594
commit 5f3466a304
12 changed files with 143 additions and 80 deletions

View file

@ -1,9 +1,5 @@
[application] [application]
name = Altair GraphQL Client name = Altair GraphQL Client
[configuration_files]
Library/Application Support/Altair GraphQL Client
snap/altair/current/.config/Altair GraphQL Client
[xdg_configuration_files] [xdg_configuration_files]
Altair GraphQL Client Altair GraphQL Client

View file

@ -1,8 +1,5 @@
[application] [application]
name = Brave name = Brave
[configuration_files]
Library/Application Support/BraveSoftware/Brave-Browser/Default
[xdg_configuration_files] [xdg_configuration_files]
BraveSoftware/Brave-Browser/Default BraveSoftware/Brave-Browser/Default

View file

@ -1,8 +0,0 @@
[application]
name = Chromium
[configuration_files]
snap/chromium/common/chromium/Default
[xdg_configuration_files]
chromium/Default

View file

@ -1,11 +1,5 @@
[application] [application]
name = Ferdium name = Ferdium
[configuration_files]
Library/Application Support/Ferdium
Library/Preferences/org.ferdium.ferdium-app.plist
snap/ferdium/current/.config/Ferdium
.var/app/org.ferdium.Ferdium/config/Ferdium
[xdg_configuration_files] [xdg_configuration_files]
Ferdium Ferdium

View file

@ -1,8 +1,5 @@
[application] [application]
name = Firefox name = Firefox
[configuration_files] [xdg_configuration_files]
Library/Application Support/Firefox/Profiles firefox/profiles
.mozilla/firefox
snap/firefox/common/.mozilla/firefox
.var/app/org.mozilla.firefox/.mozilla/firefox

View file

@ -1,8 +1,5 @@
[application] [application]
name = Edge name = Edge
[configuration_files]
Library/Application Support/Microsoft Edge/Default
[xdg_configuration_files] [xdg_configuration_files]
microsoft-edge/Default microsoft-edge/Default

View file

@ -0,0 +1,40 @@
# Application Settings Backup
The command-line utility [`mackup`](https://github.com/lra/mackup) provides a decent starting point to enable Install Doctor to provide the capability of backing up personalized application settings. `mackup` has a shortcoming though. It was not designed to accompany configurations that end up being stored in different places on different operating systems / package managers.
### Mackup
For this reason, we use `mackup` to handle the back-up and restore of the "golden" copy of application settings which will usually be stored in the `~/.config` directory. In some cases, we can get away with, for example, symlinking the `~/.config/ABC` to `~/Library/Application Settings/ABC`. But, in other cases like Flatpak, we need to keep the Flatpak configuration stored under `~/.var/com.abc.XYZ` synchronized with `~/.config/ABC`.
## `software.yml` Application Setting Definitions
The `mackup` configurations will handle the backing up of the "golden" copy and the technical package manager specific linking / synchronization is handled by our CLI. If you browse through the `software.yml` file, you will see something like the following which provides enough details to our CLI to handle the technical details:
```yaml
google-chrome:
_name: Google Chrome
_app: Google Chrome.app
_link:cask:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/google-chrome/Default"
target: "$HOME/Library/Application Support/Google/Chrome/Default"
_link:choco: 'TODO'
_link:flatpak:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/google-chrome/Default"
target: "$HOME/.var/app/com.google.Chrome/config/google-chrome/Default"
cask: google-chrome
choco: googlechrome
flatpak: com.google.Chrome
yay: google-chrome
```
The keys that start with `_link` add the instructions necessary to synchronize the configurations amongst the various possible locations in the most efficient manner. The `cask` and `flatpak` have their definitions in place. The `choco` still needs some work. And the `yay` option needs no definition because the configuration is already in the proper place by default for unrestricted system package managers.
## `backup-apps` Script
On a side note, once the proper application definitions are in place in the `software.yml` file and the proper configurations are made in this folder's `.mackup` folder, then you can use our convienience script located at `~/.local/bin/backup-apps` to perform the backup. It was created to avoid having to leave a `~/.mackup` folder and a `~/.mackup.cfg` file in the home directory.
## TODO
We need to go through the `software.yml` file and figure out which applications would benefit from application setting synchronization. Basically, any application that has `cask` and `flatpak` options will need to be configured. It is possible that some settings might reside outside of `~/Library/Application Support`.
For now, the `choco` definitions should use Unix style forward slash definitions along with `%APPDATA%` to define the location of the settings.

View file

@ -54,7 +54,6 @@ export PATH="$HOME/.local/bin/docker:$PATH"
export PATH="$HOME/.local/bin/firejail:$PATH" export PATH="$HOME/.local/bin/firejail:$PATH"
export PATH="$HOME/.local/bin/flatpak:$PATH" export PATH="$HOME/.local/bin/flatpak:$PATH"
export PATH="$HOME/.local/bin/gpt:$PATH" export PATH="$HOME/.local/bin/gpt:$PATH"
export PATH="$HOME/.local/bin/mackup:$PATH"
export PATH="$HOME/.local/bin/pipx:$PATH" export PATH="$HOME/.local/bin/pipx:$PATH"
export SSH_KEY_PATH="$HOME/.ssh/id_rsa" export SSH_KEY_PATH="$HOME/.ssh/id_rsa"

View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
# @file ~/.local/bin/backup-apps
# @brief Creates a wrapper around `mackup` to add support for XDG directories
# @description
# This script is a wrapper around the `mackup`. `Mackup` does not support XDG specification
# for its configuration. The script symlinks the `.config/mackup/.mackup/` folder to `~/.mackup` and
# the `.config/mackup/.mackup.cfg` file to `~/.mackup.cfg` before executing `mackup`. The symlinks
# are deleted after mackup runs.
#
# [mackup](https://github.com/lra/mackup) is a tool that can help in keeping your application settings
# in sync across multiple computers. It supports many different storage solutions like Dropbox, Google Drive, etc.
# to store the settings and sync them across machines. It can also help in restoring settings on a new installation.
# A number of applications are supported out of the box. It is trivial to add more applications. Refer to the
# [documentation](https://github.com/lra/mackup/blob/master/doc) for details.
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
if command -v mackup > /dev/null; then
### Create symlinks pointing to stored configurations
logg info 'Symlinking ~/.mackup and ~/.mackup.cfg'
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/mackup/.mackup/" ~/.mackup
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/mackup/.mackup.cfg" ~/.mackup.cfg
### Run mackup
logg info 'Running mackup'
mackup $* || echo ''
### Remove temporary configuration files
logg info 'Removing symlinked ~/.mackup and ~/.mackup.cfg configurations'
rm -f ~/.mackup
rm -f ~/.mackup.cfg
### Print success message
logg success 'Successfully ran backup-apps'
else
logg error 'mackup is not installed' && exit 1
fi

View file

@ -1,39 +0,0 @@
{{- if ne .host.distro.family "windows" -}}
#!/usr/bin/env bash
# @file ~/.local/bin/mackup
# @brief Creates a wrapper around `mackup` to add support for XDG directories
# @description
# This script is a wrapper around the `mackup`. `Mackup` does not support XDG specification
# for its configuration. The script symlinks the `.config/mackup/.mackup/` folder to `~/.mackup` and
# the `.config/mackup/.mackup.cfg` file to `~/.mackup.cfg` before executing `mackup`. The symlinks
# are deleted after mackup runs.
#
# [mackup](https://github.com/lra/mackup) is a tool that can help in keeping your application settings
# in sync across multiple computers. It supports many different storage solutions like Dropbox, Google Drive, etc.
# to store the settings and sync them across machines. It can also help in restoring settings on a new installation.
# A number of applications are supported out of the box. It is trivial to add more applications. Refer to the
# [documentation](https://github.com/lra/mackup/blob/master/doc) for details.
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
### Create symlinks pointing to stored configurations
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/mackup/.mackup/" ~/.mackup
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/mackup/.mackup.cfg" ~/.mackup.cfg
### Run original mackup executable
if command -v brew > /dev/null && brew list | grep mackup > /dev/null; then
$(brew --prefix)/bin/mackup $* || echo ''
elif (command -v pip3 > /dev/null && pip3 list | grep mackup > /dev/null) || \
(command -v pip > dev/null && pip3 list | grep mackup > /dev/null) || \
(command -v pipx > dev/null && pipx list | grep mackup > /dev/null); then
~/.local/bin/mackup $* || echo ''
else
logg warn 'Homebrew/Python pip is not found. Install mackup using one of these methods'
fi
### Remove temporary configuration files
rm -f ~/.mackup
rm -f ~/.mackup.cfg
{{ end }}

View file

@ -519,6 +519,13 @@ softwarePackages:
_home: https://altairgraphql.dev/ _home: https://altairgraphql.dev/
_name: Altair GraphQL Client _name: Altair GraphQL Client
_app: Altair GraphQL Client.app _app: Altair GraphQL Client.app
_link:cask:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/Altair GraphQL Client"
target: "$HOME/Library/Application Support/Altair GraphQL Client"
_link:choco: 'TODO'
_link:snap:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/Altair GraphQL Client"
target: "$HOME/snap/altair/current/.config/Altair GraphQL Client"
cask: altair-graphql-client cask: altair-graphql-client
choco: altair-graphql choco: altair-graphql
snap: altair snap: altair
@ -1645,7 +1652,18 @@ softwarePackages:
_home: https://brave.com/ _home: https://brave.com/
_name: Brave Browser _name: Brave Browser
_app: Brave Browser.app _app: Brave Browser.app
ansible: professormanhattan.bravebrowser _link:cask:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/BraveSoftware/Brave-Browser/Default"
target: "$HOME/Library/Application Support/BraveSoftware/Brave-Browser/Default"
_link:choco:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/BraveSoftware/Brave-Browser/Default"
target: "%APPDATA%/Local/BraveSoftware/Brave-Browser/User Data"
_link:flatpak:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/BraveSoftware/Brave-Browser/Default"
target: "$HOME/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser/Default"
_link:snap:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/BraveSoftware/Brave-Browser/Default"
target: "$HOME/snap/brave/current/.config/BraveSoftware/Brave-Browser/Default"
cask: brave-browser cask: brave-browser
choco: brave choco: brave
flatpak: com.brave.Browser flatpak: com.brave.Browser
@ -1870,13 +1888,12 @@ softwarePackages:
_home: https://www.google.com/chrome/ _home: https://www.google.com/chrome/
_name: Google Chrome _name: Google Chrome
_app: Google Chrome.app _app: Google Chrome.app
_post:cask: | _link:cask:
mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/google-chrome/Default" - src: "${XDG_CONFIG_HOME:-$HOME/.config}/google-chrome/Default"
mkdir -p "$HOME/Library/Application Support/Google/Chrome" target: "$HOME/Library/Application Support/Google/Chrome/Default"
ln -s "${XDG_CONFIG_HOME:-$HOME/.config}/google-chrome/Default" "$HOME/Library/Application Support/Google/Chrome/Default" _link:flatpak:
_post:flatpak: | - src: "${XDG_CONFIG_HOME:-$HOME/.config}/google-chrome/Default"
mkdir -p "" target: "$HOME/.var/app/com.google.Chrome/config/google-chrome/Default"
ln -s
ansible: professormanhattan.chrome ansible: professormanhattan.chrome
cask: google-chrome cask: google-chrome
choco: googlechrome choco: googlechrome
@ -3383,7 +3400,21 @@ softwarePackages:
_home: https://www.mozilla.org/en-US/firefox/new/ _home: https://www.mozilla.org/en-US/firefox/new/
_name: Mozilla Firefox _name: Mozilla Firefox
_app: Firefox.app _app: Firefox.app
ansible: professormanhattan.firefox _link:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/profiles"
target: "$HOME/.mozilla/firefox"
_link:cask:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/profiles"
target: "$HOME/Library/Application Support/Firefox/Profiles"
_link:choco:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/profiles"
target: 'TODO'
_link:flatpak:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/profiles"
target: "$HOME/.var/app/org.mozilla.firefox/.mozilla/firefox"
_link:snap:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/firefox/profiles"
target: "$HOME/snap/firefox/common/.mozilla/firefox"
apt: firefox apt: firefox
apt:debian: firefox-esr apt:debian: firefox-esr
cask: firefox cask: firefox
@ -5793,9 +5824,20 @@ softwarePackages:
ferdium: ferdium:
_bin: ferdium _bin: ferdium
_app: Ferdium.app _app: Ferdium.app
_link:cask:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/Ferdium"
target: "$HOME/Library/Application Support/Ferdium"
_link:choco: 'TODO'
_link:flatpak:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/Ferdium"
target: "$HOME/.var/app/org.ferdium.Ferdium/config/Ferdium"
_link:snap:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/Ferdium"
target: "$HOME/snap/ferdium/current/.config/Ferdium"
cask: ferdium cask: ferdium
choco: ferdium choco: ferdium
flatpak: org.ferdium.Ferdium flatpak: org.ferdium.Ferdium
snap: ferdium
thunderbird: thunderbird:
_bin: thunderbird _bin: thunderbird
_app: Thunderbird.app _app: Thunderbird.app
@ -5925,7 +5967,11 @@ softwarePackages:
_home: https://www.microsoft.com/en-us/edge _home: https://www.microsoft.com/en-us/edge
_name: Microsoft Edge _name: Microsoft Edge
_app: Microsoft Edge.app _app: Microsoft Edge.app
ansible: professormanhattan.microsoftedge _link:cask:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/microsoft-edge/Default"
target: "$HOME/Library/Application Support/Microsoft Edge/Default"
_link:choco: 'TODO'
_link:flatpak: 'TODO'
cask: microsoft-edge cask: microsoft-edge
choco: microsoft-edge choco: microsoft-edge
flatpak: com.microsoft.Edge flatpak: com.microsoft.Edge
@ -8119,12 +8165,18 @@ softwarePackages:
- remmina - remmina
- xrdp - xrdp
remmina: remmina:
_bin: null _bin: remmina
_desc: Remmina is a GTK Remmina Remote Desktop Client which provides remote access, screen and file sharing to your desktop _desc: Remmina is a GTK Remmina Remote Desktop Client which provides remote access, screen and file sharing to your desktop
_docs: https://gitlab.com/Remmina/Remmina/-/wikis/home _docs: https://gitlab.com/Remmina/Remmina/-/wikis/home
_github: null _github: null
_home: https://remmina.org/ _home: https://remmina.org/
_name: Remmina _name: Remmina
_link:flatpak:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/remmina/remmina.pref"
target: "$HOME/.var/app/org.remmina.Remmina/config/remmina/remmina.pref"
_link:snap:
- src: "${XDG_CONFIG_HOME:-$HOME/.config}/remmina/remmina.pref"
target: "$HOME/snap/remmina/current/.config/remmina/remmina.pref"
apt: remmina apt: remmina
dnf: remmina dnf: remmina
flatpak: org.remmina.Remmina flatpak: org.remmina.Remmina