Skip to main content

YAML config based backup utility. Easy to use yet flexible. With a primary focus on dotfile backup & setup, but not limited to dotfiles.

Project description

dotbackup

PyPI - Python Version PyPI - Version PyPI - Downloads AUR version

Code style: black Lint: flake8 Imports: isort Test: pytest Codecov

YAML config based backup utility. Easy to use yet flexible. With a primary focus on dotfile backup & setup, but not limited to dotfiles.

Features

  • Simple configuration.
  • Custom hooks.

Installation

You can download the script and place it to somewhere you like:

curl -L -o ~/.local/bin/dotbackup \
    "https://github.com/jaxvanyang/dotbackup/raw/main/src/dotbackup.py"
chmod +x ~/.local/bin/dotbackup

Or you can install from one of these package managers:

Configuration

The default configuration file path is ~/.config/dotbackup/dotbackup.yml, however you can use the -c option to specify another configuration file. Configuration files use YAML syntax. If you are new to YAML and want to learn more, see Learn yaml in Y Minutes. If you want a quick start, you can take this as an example. Following are the configuration keyword definitions, undefined keywords are ignored (maybe I'll write a validator someday).

backup_dir

Required. The directory where backup files be stored.

Example:

backup_dir: ~/dotfiles

apps.<app>.files

Optional. The files to be backed up of the application <app>, <app> can be any string. File paths MUST be under the $HOME directory due to implementation. You can use custom hooks to back up other files.

Example:

apps:
  nvim:
    files:
      - ~/.config/nvim/init.lua
      - ~/.config/nvim/lua

apps.<app>.ignore

Optional. The Application ignored file patterns. Files that matches these patterns will be ignored in backup and setup. But files which are directly specified in apps.<app>.files will not be ignored.

Example:

apps:
  nvim:
    files: [~/.config/nvim]
    ignore: ['*.json']

apps.<app>.<pre_backup|post_backup|pre_setup|post_setup>

Optional. The hooks to be executed before/after <app> backup/setup, <app> can be any string. Each hook accept a list of commands, command are passed to sh -c. You can use these hooks to do advance operation.

Example:

FIXME: defining BACKUP_DIR is not implemented yet.

apps:
  dotbackup:
    pre_backup:
      - cp /etc/dotbackup/dotbackup.yml "$BACKUP_DIR/dotbackup/dotbackup.yml"
    post_backup:
      - cd "$BACKUP_DIR" && git add dotbackup
    pre_setup:
      - pip install --user dotbackup || true
    post_setup:
      - sudo cp "$BACKUP_DIR/dotbackup/dotbackup.yml" /etc/dotbackup/dotbackup.yml

ignore

Optional. The global ignored file patterns. Files that matches these patterns will be ignored in backup and setup. But files which are directly specified in apps.<app>.files will not be ignored.

Example:

apps:
  nvim:
    files: [~/.config/nvim]
ignore: ['.git']

<pre_backup|post_backup|pre_setup|post_setup>

Optional. The hooks to be executed before/after all backup/setup. Each hook accept a list of commands, command are passed to sh -c. You can use these hooks to do advance operation.

Example:

FIXME: defining BACKUP_DIR is not implemented yet.

pre_backup:
  - date > "$BACKUP_DIR/backup_date.txt"
post_backup:
  - |
    cd "$BACKUP_DIR"
    git add backup_date.txt
    git commit -m "update backups"
    git push
pre_setup:
  - cd "$BACKUP_DIR" && git pull
post_setup:
  - paru -Syu base-devel

Usage

Some examples:

dotbackup nvim tmux
dotbackup backup nvim tmux
dotbackup setup nvim tmux
dotbackup setup

Run dotbackup -h for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dotbackup-0.0.5.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

dotbackup-0.0.5-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file dotbackup-0.0.5.tar.gz.

File metadata

  • Download URL: dotbackup-0.0.5.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for dotbackup-0.0.5.tar.gz
Algorithm Hash digest
SHA256 dab0d9ceb299d47c97486e9ddb1b245356d4be7afca4986071829eda0a1e97c1
MD5 0d5412f376cb8430386360122a429085
BLAKE2b-256 394a3fc7a02b98d127c96df6cca2334bc9b5483dec23573bed8383b802d1a01a

See more details on using hashes here.

Provenance

File details

Details for the file dotbackup-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: dotbackup-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for dotbackup-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0654116c86e0575a1372b9bccc0f0ba3c5fa7f8c604d6ef4ad9e3b0bc7a8e893
MD5 77b123898caa78a1f49fd0a3609323da
BLAKE2b-256 c4908da2910f28dfad64a2f2174b465e49ee6ddffdb6a9e9ff2dce0ce7ca8cef

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page