All Projects โ†’ alichtman โ†’ Shallow Backup

alichtman / Shallow Backup

Licence: mit
Git-integrated backup tool for macOS and Linux devs.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Shallow Backup

Gobackup
๐Ÿ—„ Simple tool for backup your databases, files to FTP / SCP / S3 storages.
Stars: โœญ 472 (-34.44%)
Mutual labels:  backup
Imap Backup
Backup GMail (or other IMAP) accounts to disk
Stars: โœญ 522 (-27.5%)
Mutual labels:  backup
Bareos
Main repository with the code for the libraries and daemons
Stars: โœญ 651 (-9.58%)
Mutual labels:  backup
Laravel Backup
A package to backup your Laravel app
Stars: โœญ 4,752 (+560%)
Mutual labels:  backup
Backup
Easy full stack backup operations on UNIX-like systems.
Stars: โœญ 4,682 (+550.28%)
Mutual labels:  backup
Velero
Backup and migrate Kubernetes applications and their persistent volumes
Stars: โœญ 5,864 (+714.44%)
Mutual labels:  backup
Qzoneexport
QQ็ฉบ้—ดๅฏผๅ‡บๅŠฉๆ‰‹๏ผŒ็”จไบŽๅค‡ไปฝQQ็ฉบ้—ด็š„่ฏด่ฏดใ€ๆ—ฅๅฟ—ใ€็งๅฏ†ๆ—ฅ่ฎฐใ€็›ธๅ†Œใ€่ง†้ข‘ใ€็•™่จ€ๆฟใ€QQๅฅฝๅ‹ใ€ๆ”ถ่—ๅคนใ€ๅˆ†ไบซใ€ๆœ€่ฟ‘่ฎฟๅฎขไธบๆ–‡ไปถ๏ผŒไพฟไบŽ่ฟ็งปไธŽไฟๅญ˜
Stars: โœญ 456 (-36.67%)
Mutual labels:  backup
Edizon
๐Ÿ’ก A homebrew save management, editing tool and memory trainer for Horizon (Nintendo Switch)
Stars: โœญ 706 (-1.94%)
Mutual labels:  backup
Mt Aws Glacier
Perl Multithreaded Multipart sync to Amazon Glacier
Stars: โœญ 522 (-27.5%)
Mutual labels:  backup
Elasticsearch Dump
Import and export tools for elasticsearch
Stars: โœญ 5,977 (+730.14%)
Mutual labels:  backup
Roam To Git
Automatic RoamResearch backup to Git
Stars: โœญ 489 (-32.08%)
Mutual labels:  backup
Kopia
Cross-platform backup tool for Windows, macOS & Linux with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication. CLI and GUI included.
Stars: โœญ 507 (-29.58%)
Mutual labels:  backup
Mgob
MongoDB dockerized backup agent. Runs schedule backups with retention, S3 & SFTP upload, notifications, instrumentation with Prometheus and more.
Stars: โœญ 573 (-20.42%)
Mutual labels:  backup
Django Dbbackup
Management commands to help backup and restore your project database and media files
Stars: โœญ 471 (-34.58%)
Mutual labels:  backup
Percona Xtrabackup
Open source hot backup tool for InnoDB and XtraDB databases
Stars: โœญ 678 (-5.83%)
Mutual labels:  backup
Signal Back
Decrypt Signal encrypted backups outside the app
Stars: โœญ 468 (-35%)
Mutual labels:  backup
Redditdownloader
Scrapes Reddit to download media of your choice.
Stars: โœญ 521 (-27.64%)
Mutual labels:  backup
Duplicati
Store securely encrypted backups in the cloud!
Stars: โœญ 6,915 (+860.42%)
Mutual labels:  backup
Rdedup
Data deduplication engine, supporting optional compression and public key encryption.
Stars: โœญ 690 (-4.17%)
Mutual labels:  backup
Btrbk
Tool for creating snapshots and remote backups of btrfs subvolumes
Stars: โœญ 605 (-15.97%)
Mutual labels:  backup

shallow-backup

Downloads Build Status Codacy Badge

shallow-backup lets you easily create lightweight backups of installed packages, applications, fonts and dotfiles, and automatically push them to a remote Git repository.

Shallow Backup GIF Demo

Contents

Why?

I wanted a tool that allows you to:

  • Back up dotfiles from where they live on the system.
  • Back up files from any path 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 manner

And is incredibly fault tolerant and user-protective.

shallow-backup is the only tool that checks all of those boxes.

Installation


Do not install this as root.

  1. Install with pip3

    • $ pip3 install shallow-backup
    • $ shallow-backup
  2. Download the shallow-backup binary from Releases tab.

Usage


To start the interactive program, simply run $ shallow-backup.

shallow-backup was built with scripting in mind. Every feature that's supported in the interactive program is supported with command line arguments.

Usage: shallow-backup [OPTIONS]

  Easily back up installed packages, dotfiles, and more.
  You can edit which files are backed up in ~/.shallow-backup.

  Written by Aaron Lichtman (@alichtman).

Options:
  --add-dot TEXT              Add a dotfile or dotfolder to config by path.
  -backup-all                 Full back up.
  -backup-configs             Back up app config files.
  -backup-dots                Back up dotfiles.
  -backup-packages            Back up package libraries.
  -delete-config              Delete config file.
  -destroy-backup             Delete backup directory.
  -dry-run                    Don't backup or reinstall any files, just give
                              verbose output.

  -backup-fonts               Back up installed fonts.
  --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't display splash screen.
  -reinstall-all              Full reinstallation.
  -reinstall-configs          Reinstall configs.
  -reinstall-dots             Reinstall dotfiles and dotfolders.
  -reinstall-fonts            Reinstall fonts.
  -reinstall-packages         Reinstall packages.
  --remote TEXT               Set remote URL for the git repo.
  -separate-dotfiles-repo     Use if you are trying to maintain a separate
                              dotfiles repo and running into issue #229.

  -show                       Display config file.
  -v, --version               Display version and author info.
  -h, -help, --help           Show this message and exit.

Git Integration


A Word of Caution

This 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-backup creates a .gitignore file if it can't find one in the directory. It excludes .ssh/ and .pypirc by 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 .gitignore file 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.

What if I'd like to maintain a separate repo for my dotfiles?

shallow-backup makes this easy! After making your first backup, cd into the dotfiles/ directory and run $ git init. Create a .gitignore and a new repo on your favorite version control platform. This repo will be maintained independently (manually) of the base shallow-backup repo. Note that you may need to use the -separate_dotfiles_repo flag to get this to work, and it may break some other functionality of the tool. It's ok for my use case, though.

Here's a bash script that I wrote to automate 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-backup backs these up.

  1. Dotfiles and dotfolders

    • .bashrc
    • .bash_profile
    • .gitconfig
    • .pypirc
    • .config/shallow-backup.conf
    • .ssh/
    • .vim/
    • .zshrc
  2. App Config Files

    • Atom
    • VSCode
    • Sublime Text 2/3
    • Terminal.app
  3. Installed Packages

    • apm
    • brew and cask
    • cargo
    • gem
    • pip
    • pip3
    • npm
    • macports
    • VSCode Extensions
    • Sublime Text 2/3 Packages
    • System Applications
  4. User installed fonts.

Configuration

If you'd like to modify which files are backed up, you have to edit the JSON config file, located at ~/.config/shallow-backup.conf. There are two ways to do this.

  1. Select the appropriate option in the CLI and follow the prompts.
  2. 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 Reinstallation

Every dotfile has two subkeys: backup_condition and reinstall_condition. Both of these accept expressions that will be evaluated in bash. An empty string ("") is the default value, and is considered to be True. If the return value of the expression is 0, this is considered True. Otherwise, it is False. 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\" ]]"

My config (as of v5.0.0a) looks like this, and is used to back up my dotfiles:

{
	"backup_path": "~/shallow-backup",
	"lowest_supported_version": "5.0.0a",
	"dotfiles": {
		".config/agignore": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/crontab": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/fzf-notes": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/git/config": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/git/gitignore_global": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/jrnl/jrnl.yaml": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/kitty": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/nvim": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/pycodestyle": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/pylintrc": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/python": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/radare2/radare2rc": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/ranger": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/shallow-backup.conf": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/starship.toml": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/tmux": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/tuir/tuir.cfg": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/zathura/zathurarc": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".config/zsh": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".ctags": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".ghc/ghci.conf": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".pypirc": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".ssh": {
			"reinstall_condition": "",
			"backup_condition": ""
		},
		".zshenv": {
			"reinstall_condition": "",
			"backup_condition": ""
		}
	},
	"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"
	}
}

.gitignore

As of v4.0, any .gitignore changes should be made in the shallow-backup config file. .gitignore changes that are meant to apply to all directories should be under the root-gitignore key. Dotfile specific gitignores should be placed under the dotfiles-gitignore key. The original default-gitignore key in the config is still supported for backwards compatibility, however, converting to the new config format is strongly encouraged.

Output Structure


backup_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
โ”‚   โ”œโ”€โ”€ Aller_BdIt.ttf
โ”‚   โ”œโ”€โ”€ Aller_It.ttf
โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ Ubuntu Mono derivative Powerline Bold Italic.ttf
โ”‚   โ”œโ”€โ”€ Ubuntu Mono derivative Powerline Bold.ttf
โ”‚   โ”œโ”€โ”€ Ubuntu Mono derivative Powerline Italic.ttf
โ”‚   โ””โ”€โ”€ Ubuntu Mono derivative Powerline.ttf
โ””โ”€โ”€ packages
    โ”œโ”€โ”€ apm_list.txt
    โ”œโ”€โ”€ 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.txt

Reinstalling Dotfiles

To reinstall your dotfiles, clone your dotfiles repo and make sure your shallow-backup config path can be found at either ~/.config/shallow-backup.conf or $XDG_CONFIG_HOME/.shallow_backup.conf. Set the backup-path key 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/ and README.md files and directories are ignored.

Want to Contribute?


Check out CONTRIBUTING.md and the docs directory.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].