My concern is to automatize the backup of my configuration files (aka dotfiles) and to generate a snapshot of all installed apps, whether it be through my distro's package manager or throw third-party package manager like
pip. This is the first step before being able to sync my apps automatically on a newly installed computer (still to be done).
What I did is create a git repo in my
$HOME dir as all my dotfiles are located here. But as I don't want to push all the other files (Pictures, Downloads, Desktop...), I put a
.gitignore file with just a wildcard (
*) in it. This way, when I want to add a file to the repo, I have to force with:
git add -f newfile.
cd ~ git init echo "*" > .gitignore git add -f .gitignore git add -f .bashrc git add -f .zshrc git add -f .config/fish git add -f .tmux.conf git add -f .SpaceVim.d/init.toml git commit -m "First commit" git remote add origin firstname.lastname@example.org:username/mydotfiles git push -u origin master
⚠️ But be aware that it could be dangerous for your sensible data. For example, don't push your
Thus, you have a quick way to retrieve your configuration in case of a computer fresh install or in case of a crash.
The next step is to do the same with your apps.
Generate a snapshot of your apps
Regarding the apps, it's not so easy. It's not unusual to have several package managers to install new apps. Personally, I use 7 of them:
pacman, the manager of my Manjaro linux distribution. Each of them has its own syntax to install, delete or update packages.
But each of them also has its own syntax to output a list of installed packages.
So basically, I just use the following bash script to generate the list of all installed packages, across all the package managers:
#!/bin/bash echo "Generating the lists of explicitly installed packages in ~/.backup" pacman -Qe > ~/.backup/pacman_packages || echo "pacman failed" gem list > ~/.backup/gem_packages || echo "gem failed" npm list -g --depth=0 > ~/.backup/npm_packages || echo "npm failed" pip list > ~/.backup/pip_packages || echo "pip failed" cargo --list | tail -n +2 | tr -d " " > ~/.backup/cargo_packages || echo "cargo failed" ghc-pkg list > ~/.backup/ghc-pkg_packages || echo "ghc-pkg failed" composer global show | cut -d ' ' -f1 > ~/.backup/composer_packages || echo "composer failed" git add -f .backup exit 0
git add command at the end of the script. I do this to automatically add the
~/.backup folder to the git index so that it gets pushed to the remote. And as I put this script in the
pre-commit hook, my packages list gets synced with git each time I commit:
biros on master [!] ➜ git commit -m "Update conf" Generating the lists of explicitly installed packages in ~/.backup [master 27f73e4] Update conf 1 file changed, 1 insertion(+)
⏭️ Next step: be able to re-install all the apps automatically from the backup.
💡 Hint: you can sync your Atom plugins with the sync-settings plugin.
📚 Other resource on the same topic: