A simple tool to back up and restore dot files (config files in Linux) for Linux OS.
- Specify backup structure in one or multiple config files.
- Back up the configured files to the directory of the config file.
- Restore the configured files from the directory of the config file.
- Environment Variable substitution in paths and names.
DotSave requires the JRE to be installed in your system to work. Check with your distro what is the best way to install it in your OS. After that just:
- Download the latest release.
- Unzip it.
- Add the directory to your
PATHvariable. - ???
- Profit!
-
First you need a place to put your backup:
mkdir ~/my-backup -
Next you need to make a config file (for example
~/my-backup/home.json) in your favorite editor:{ "profiles": [ { "name": "Home Base", "default": true, "root": "${HOME}", "include": [ ".config/neofetch/config.conf" ], "ignore": [ ".npm/" ] } ] }Each
profilewill store all the files and directories specified ininclude, except for files and directories specified inignore, in the parent directory of the config file and the name of the profile. For example, the JSON above will store its profile in~/my-backup/Home Base. Files and directories should preserve their owner and permissions. The tool will also check the root directory of the profile for files not included or ignored and will issue a warning that those files will be implicitly ignored until explicitly included or ignored. This way you can discover if a new file was added by an existing or new app.[!WARNING] If you ignore a directory and later a file is added to that directory, the tool won't be able to detect this. Be sure files won't be added or that files added to the directory won't ever matter.
[!NOTE] Notice that the environment variable
HOMEwas used as root of the profile. At runtime, the variable will be evaluated and replaced. You can use environment variables in all string properties by using the${NAME}notation. -
Now just execute the tool with the
-boption to back up!dotsave -b ~/my-backup/home.json -
To restore, just use the
-roption:dotsave -r ~/my-backup/home.json
Important
You can create a separate config file that backups files owned by root and use sudo just with that config file!
Sometimes you may have multiple devices which you want to share certain configuration between them, but not all. You can add more profiles to the config file and compose a profile from other using includeProfiles and inheritProfiles. For example:
{
"profiles": [
{
"name": "Neofetch",
"root": "${HOME}/.config/neofetch",
"include": [
"config.conf"
],
"ignore": []
},
{
"name": "FreeCAD",
"root": "${HOME}/.config/FreeCAD",
"include": [
"FreeCAD.conf",
"system.cfg",
"user.cfg"
],
"ignore": []
},
{
"name": "BatteryMonitor",
"root": "${HOME}/.config/BatteryMonitor",
"include": [
"config.conf"
],
"ignore": []
},
{
"name": "KDE",
"root": "${HOME}/.config",
"include": [
"kde.org/*"
],
"ignore": []
},
{
"name": "Shared",
"root": "${HOME}",
"inheritProfiles": [
"Neofetch"
],
"include": [],
"ignore": []
},
{
"name": "Desktop",
"default": true,
"root": "${HOME}",
"includeProfiles": [
"Shared"
],
"inheritProfiles": [
"FreeCAD",
"KDE"
],
"include": [],
"ignore": [
".gradle/"
]
},
{
"name": "Laptop",
"root": "${HOME}",
"includeProfiles": [
"Shared"
],
"inheritProfiles": [
"BatteryMonitor",
"KDE"
],
"include": [],
"ignore": []
}
]
}Let's assume we run the Desktop profile with dotsave -b ~/my-backup/home.json -p Desktop:
Desktopprofile will first execute the profiles in theincludeProfileslist, in this caseShared. So we will end with a directory~/my-backup/Shared.Sharedprofile doesn't have anyincludeProfilesso it will skip that step. Instead, it will merge in itself all the profiles ininheritProfiles, in this caseNeofetch. so we will have a file backed up at~/my-backup/Shared/.config/neofetch/config.conf. Notice there is no top level "Neofetch" directory, is it inside "Shared".- After executing
Shared,Desktopwill merge the profiles ininheritProfileswhich areFreeCADandKDE. So a~/my-backup/Desktop/directory will be created and back up the files like~/my-backup/Desktop/.config/FreeCAD/FreeCAD.confand~/my-backup/Desktop/.config/kde.org/plasmashell.conf.
Note
Note that both Desktop and Laptop profiles inherit KDE, but the KDE backups will be stored in different directories, so the contents of the files can be different. Likewise, both of them include Shared, which will be stored in the same Shared directory and thus shared between the two profiles.
Important
You can mark a profile as the default with the default property so you don't need to specify the profile name in the command line. Only one profile can be marked as default.
Tip
You can version your backups using git in case you ever want to go back to a previous configuration.
These are other command line arguments you can use:
-vor--verbose- Activates verbose mode to get a more detailed idea of what the tool is doing.-dor--dry-run- Activates simulation mode where no changes to the filesystem will be done. Most useful when mixed with verbose mode.
This project is under the GNU GPL-3.0 license.
- If you have issues with DotSave, please open a bug report with as detailed information on how to reproduce the issue, and I'll try to fix it.
- If you wish to improve DotSave, please submit a PR with your changes and I will review them.
You can always buy me a coffee here: