Skip to main content

Dotfiles backup and restore tool

Project description

dbkp - dotfiles backup

dbkp simply backups and restores dotfiles using rsync -La. You can use it with any version control or backup strategy you want.

Instalation

Install with pip:

pip3 install dbkp

Usage

Put the file dbkp.json on a folder and configure it as you want. Then either run dbkp backup from the folder or pass the path to the configuration file as dbkp backup /path/to/dbkp.json. A folder named dotfiles in the same folder as the configuration file will be created and all dotfiles will be synced inside it. Use dbkp restore in the same way to rsync the files from the dotfiles folder into their places.

Configuration example

The configuration is a list of files to backup, or objects that adds some features to the specific dotfile.

A string will backup the folder/file. This will backup the file ~/.vimrc:

["~/.vimrc"]

It is the same as

[
  {
    "path": "~/.vimrc",
    "alias": "vimrc"
  }
]

alias is the name the file/folder will have inside the dotfiles folder. By default it is the name of the file/folder without a leading dot.

It is also possible to exclude subfiles/subfolders from a folder. The complete folder will be synced and then the files/folders will be deleted. You can specify both only and exclude, but exclude will be ignored in this case. only will remove all files but the ones listed and exclude will only exclude the ones listed.

[
  {
    "path": "~/.config/fish",
    "only": ["functions"],
    "exclude": ["completions"]
  }
]

The links options allows to create symlinks after restoring. It is a list of either strings or lists of 2 string elements. If the element is a string, then a symlink will be created pointing to path. If it a list of 2 strings, the second is the symlink and will point to path/first element. In the example, ~/.vimrc will point to ~/.config/nvim/init.nvim and ~/neovim will point to ~/.config/nvim.

[
  {
    "path": "~/.config/nvim",
    "links": ["~/neovim", ["init.vim", "~/.vimrc"]]
  }
]

It is also possible to run commands to do the backup/restore.

[
  {
    "backup": "brew leaves",
    "restore": "xargs brew install",
    "alias": "brew.leaves"
  }
]

This is the same as backing up with

brew leaves > brew.leaves

and then restoring with

cat brew.leaves | xargs brew install

The current working directory is changed to the folder containing the configuration file before executing anything, so if you want to specify files in the command line, remember that: you need to quote file paths if they contain spaces and your alias file is in dotfiles/:alias".

LICENSE

The MIT License (MIT)

Copyright (c) 2021 Álan Crístoffer e Sousa

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

dbkp-1.0.5.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

dbkp-1.0.5-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file dbkp-1.0.5.tar.gz.

File metadata

  • Download URL: dbkp-1.0.5.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Linux/6.1.52-valve10

File hashes

Hashes for dbkp-1.0.5.tar.gz
Algorithm Hash digest
SHA256 8a026e2323f4feaecb24339e9fd924145d80eb884bad0656ed7217a6553d0470
MD5 68f53fcdbc78952a223750ac2476fa0e
BLAKE2b-256 98a599f4970ac56ef5573c4ac50401cecd3347425a84c682bf7ea33312666ea0

See more details on using hashes here.

File details

Details for the file dbkp-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: dbkp-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Linux/6.1.52-valve10

File hashes

Hashes for dbkp-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 918d50b5942ec9a6ada962634e990d8d48df1cea408ed58e5e7b8fd804e50668
MD5 c75ea7e43cced9df008d47b31af69b67
BLAKE2b-256 769ce6386bdabce5674f87a6912a67480e5cbc5d020f7dccac55ed8902adf699

See more details on using hashes here.

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