Package: shallow-backup
shallow-backupshallow-backuplets you easily create lightweight backups of installed packages, applications, fonts and dotfiles, and automatically push them to a remote Git repository.ContentsWhy?InstallationUsageGit IntegrationWhat can I back up?ConfigurationOutput StructureReinstalling DotfilesWant to contribute?Why?I wanted a tool that allows you to:Back up dotfilesfrom where they live on the system.Back up files fromanypath on the system, not just$HOME.Reinstall them from the backup directory idempotently.Backup and reinstall files conditionally, so you can easily manage dotfiles across multiple systems.Copy files on installation and backup, as opposed to symlinking them.Backup package installations in a highly compressed mannerAnd is incredibly fault tolerant and user-protective.shallow-backupis the only tool that checks all of those boxes.InstallationWarningBe careful running this with elevated privileges. Code execution can be achieved with write permissions on the config file.Method 1:pipx$pipxinstallshallow-backupMethod 2: Install From Source$gitclonehttps://www.github.com/alichtman/shallow-backup.git
$cdshallow-backup
$pip3install.Dependenciespre-committrufflehogIf you are missing the dependencies, you will be guided to install them.UsageTo start the interactive program, simply run$ shallow-backup.shallow-backupwas built with scripting in mind. Every feature that's supported in the interactive program is supported with command line arguments.Usage:shallow-backup[OPTIONS]Easilybackupinstalledpackages,dotfiles,andmore.Youcaneditwhichfilesarebackedupin~/.shallow-backup.WrittenbyAaronLichtman(@alichtman).

Options:--add-dotTEXTAddadotfileordotfoldertoconfigbypath.--backup-allFullbackup.--backup-configsBackupappconfigfiles.--backup-dotsBackupdotfiles.--backup-fontsBackupinstalledfonts.--backup-packagesBackuppackagelibraries.--delete-configDeleteconfigfile.--destroy-backupDeletebackupdirectory.--dry-runDon't backup or reinstall any files, just giveverbose output.--new-path TEXT              Input a new back up directory path.--no-new-backup-path-prompt  Skip setting new back up directory path prompt.--no-splash                  Don'tdisplaysplashscreen.--reinstall-allFullreinstallation.--reinstall-configsReinstallconfigs.--reinstall-dotsReinstalldotfilesanddotfolders.--reinstall-fontsReinstallfonts.--reinstall-packagesReinstallpackages.--remoteTEXTSetremoteURLforthegitrepo.--showDisplayconfigfile.-v,--versionDisplayversionandauthorinfo.-h,-help,--helpShowthismessageandexit.Git IntegrationA Word of CautionThis backup tool is git-integrated, meaning that you can easily store your backups remotely (on GitHub, for example.) Dotfiles and configuration files may contain sensitive information like API keys and ssh keys, and you don't want to make those public. To make sure no sensitive files are uploaded accidentally,shallow-backupcreates a.gitignorefile if it can't find one in the directory. It excludes.ssh/and.pypircby default. It's safe to remove these restrictions if you're pushing to a remote private repository, or you're only backing up locally. To do this, you should clear the.gitignorefile without deleting it.If you choose to back up to a public repository, look at every file you're backing up to make sure you want it to be public.NOTE: As ofv6.2,trufflehogis run as a required precommit hook and will detect secrets.How can I maintain a separate repo for my dotfiles?shallow-backupmakes this easy! After making your first backup,cdinto thedotfiles/directory and run$ git init. Create a.gitignore, and a create / set up (link the upstream remote, etc) a new repo on your favorite version control platform. With operations involving the parentshallow-backuprepo,shallow-backupwill prompt you interactively to update the nested submodule. After that is taken care of,shallow-backupwill move on to updating the parent. Thedotfilesrepo will be tracked as a submodule.Here's abashscript that I wrote toautomate my dotfile backup workflow. You can use this by placing it in your$PATH, making it executable, and running it.What can I back up?By default,shallow-backupbacks these up.Dotfiles and dotfolders.bashrc.bash_profile.gitconfig.pypirc.config/shallow-backup.conf.ssh/.vim/.zshrcApp Config FilesAtomVSCodeSublime Text 2/3Terminal.appInstalled Packagesbrewandcaskcargogempippip3npmmacportsVSCodeExtensionsSublime Text 2/3PackagesSystem ApplicationsUser installedfonts.ConfigurationIf you'd like to modify which files are backed up, you have to edit theJSONconfig file, located at~/.config/shallow-backup.conf. There are two ways to do this.Select the appropriate option in the CLI and follow the prompts.Open the file in a text editor and make your changes.Editing the file in a text editor will give you more control and be faster.Conditional Backup and ReinstallationWarningThis feature allows code execution (by design). If untrusted users can write to your config, they can achieve code execution next time you invokeshallow-backupbackuporreinstallfunctions. Starting inv5.2, the config file will have default permissions of644, and a warning will be printed if others can write to the config.Every key under dotfiles has two optional subkeys:backup_conditionandreinstall_condition. Both of these accept expressions that will be evaluated withbash. An empty string ("") is the default value, and is considered to beTrue. If the return value of the expression is0, this is consideredTrue. Otherwise, it isFalse. This lets you do simple things like preventing backup with:// Because `$ false` returns 1"backup_condition":"false"And also more complicated things like only backing up certain files if an environment variable is set:"backup_condition":"[[ -n \"$ENV_VAR\" ]]"Here's an example config based on mydotfiles:{"backup_path":"~/shallow-backup","lowest_supported_version":"5.0.0a","dotfiles":{".config/agignore":{"backup_condition":"uname -a | grep Darwin","reinstall_conditon":"uname -a | grep Darwin"},".config/git/gitignore_global":{},".config/jrnl/jrnl.yaml":{},".config/kitty":{},".config/nvim":{},".config/pycodestyle":{},...".zshenv":{}},"root-gitignore":[".DS_Store","dotfiles/.config/nvim/.netrwhist","dotfiles/.config/nvim/spell/en.utf-8.add","dotfiles/.config/ranger/plugins/ranger_devicons","dotfiles/.config/zsh/.zcompdump*","dotfiles/.pypirc","dotfiles/.ssh"],"dotfiles-gitignore":[".DS_Store",".config/nvim/.netrwhist",".config/nvim/spell/en.utf-8.add*",".config/ranger/plugins/*",".config/zsh/.zcompdump*",".config/zsh/.zinit",".config/tmux/plugins",".config/tmux/resurrect",".pypirc",".ssh/*"],"config_mapping":{"/Users/alichtman/Library/Application Support/Sublime Text 2":"sublime2","/Users/alichtman/Library/Application Support/Sublime Text 3":"sublime3","/Users/alichtman/Library/Application Support/Code/User/settings.json":"vscode/settings","/Users/alichtman/Library/Application Support/Code/User/Snippets":"vscode/Snippets","/Users/alichtman/Library/Application Support/Code/User/keybindings.json":"vscode/keybindings","/Users/alichtman/.atom":"atom","/Users/alichtman/Library/Preferences/com.apple.Terminal.plist":"terminal_plist"}}.gitignoreAs ofv4.0, any.gitignorechanges should be made in theshallow-backupconfig file..gitignorechanges that are meant to apply to all directories should be under theroot-gitignorekey. Dotfile specific gitignores should be placed under thedotfiles-gitignorekey. The originaldefault-gitignorekey in the config is still supported for backwards compatibility, however, converting to the new config format is strongly encouraged.Output Structurebackup_dir/
├──configs
│├──plist
││└──com.apple.Terminal.plist
│├──sublime_2
││└──...
│└──sublime_3
│└──...
├──dotfiles
│├──.bash_profile
│├──.bashrc
│├──.gitconfig
│├──.pypirc
│├──...
│├──.shallow-backup
│├──.ssh/
││└──known_hosts
│├──.vim/
│└──.zshrc
├──fonts
│├──AllerDisplay.ttf
│├──Aller_Bd.ttf
│├──...
│├──UbuntuMonoderivativePowerlineItalic.ttf
│└──UbuntuMonoderivativePowerline.ttf
└──packages├──brew-cask_list.txt├──brew_list.txt├──cargo_list.txt├──gem_list.txt├──installed_apps_list.txt├──npm_list.txt├──macports_list.txt├──pip_list.txt└──sublime3_list.txtReinstalling DotfilesTo reinstall your dotfiles, clone your dotfiles repo and make sure your shallow-backup config path can be found at either~/.config/shallow-backup.confor$XDG_CONFIG_HOME/.shallow_backup.conf. Set thebackup-pathkey in the config to the path of your cloned dotfiles. Then run$ shallow-backup -reinstall-dots.When reinstalling your dotfiles, the top level.git/,.gitignore,img/andREADME.mdfiles and directories are ignored.Want to Contribute?Check outCONTRIBUTING.mdand thedocsdirectory.