项目作者: Czaporka

项目描述 :
Back up your stuff!
高级语言: Python
项目地址: git://github.com/Czaporka/back-up.git
创建时间: 2021-01-09T20:20:56Z
项目社区:https://github.com/Czaporka/back-up

开源协议:

下载


back-up

https://github.com/Czaporka/back-up/actions
codecov

Description

back-up is a very simple utility for backing up directories of files.

Features

  • Awfully simple.
  • Configured with a YAML configuration file, where you can specify what directories
    should be backed up, and where the backups should be stored.
  • For each directory to back up, it checks whether its contents have changed since
    the last time it was backed up. If not, then back-up will not waste disk space
    by creating another copy. This means that it can simply be called at regular
    intervals, e.g. scheduled with cron or Task Scheduler to run every 1 hour or so.

Installation

  1. pip install back-up

Configuration

back-up reads the configuration from file ~/.config/back-up/back-up.yaml. That is where you should specify all the directories you want backed up. See sample back-up.yaml file for available configuration options.

It is also possible, albeit usually impractical, to specify all the parameters on the command line.

Usage

  1. usage: back-up [-h] [--backups-dir PATH] [--log-file PATH]
  2. [--logging-level {CRITICAL,ERROR,WARNING,INFO,DEBUG}]
  3. [--to-backup NAME=PATH [NAME=PATH ...]] [--config-file PATH]
  4. [--archive-format FORMAT] [--version] [--verbose] [--quiet]
  5. Utility for backing up directories.
  6. optional arguments:
  7. -h, --help show this help message and exit
  8. --backups-dir PATH set the directory to dump the backups to; this is the
  9. 'general' backups directory, i.e. specific
  10. directories that you back up will have their own
  11. subdirectories in there
  12. --log-file PATH set the file to dump logs to
  13. --logging-level {CRITICAL,ERROR,WARNING,INFO,DEBUG}
  14. set logging verbosity
  15. --to-backup NAME=PATH [NAME=PATH ...]
  16. set the directories to back up; PATH is the directory
  17. to back up, NAME is an arbitrary identifier used to
  18. organize the backup files in the backup directory, so
  19. it's easier to find the thing you want to restore;
  20. sample value: 'DOCUMENTS=~/Documents' (the tilde will
  21. be expanded appropriately, backups will be dumped
  22. under '<backups_dir>/DOCUMENTS/...')
  23. --config-file PATH where to take config from; command line arguments
  24. have priority though; default: '~/.config/back-
  25. up/back-up.yaml'
  26. --archive-format FORMAT
  27. what format to store the backups in; default: 'zip'
  28. --version, -V show version and exit
  29. --verbose, -v increase verbosity of console output
  30. --quiet, -q decrease verbosity of console output

Development

Prepare environment

  1. python3 -m venv .env
  2. source .env/bin/activate
  3. pip install --editable .
  4. pip install coverage pycodestyle

Run tests, generate coverage reports etc.

  1. coverage run --source back_up/ -m unittest discover tests/
  2. coverage report
  3. coverage html
  4. pycodestyle back_up/ tests/
  5. # same thing but on one line:
  6. coverage run --source back_up/ -m unittest discover tests/ \
  7. && coverage report \
  8. && coverage html \
  9. && pycodestyle back_up/ tests/

TODO

  • Add some sort of cleanup capability for really old backups.