Skip to main content

Defines your backup strategy based on bash commands

Project description

Bashbackup Test codecov GitHub tag (latest SemVer) PyPI PyPI - Python Version PyPI - License

It is a python application that allows you to easily describe the backup steps you want. It is possible to describe the steps in YAML or in CLI. The tool also allows to manage the restoration based on the backup steps.

Installation

pip install bashckup

Examples

Backup with YAML file

bashckup backup file --config-file /home/bashckup/config.yml

Restoration with YAML file

bashckup restore file --config-file /home/bashckup/config.yml

Config file:

Show up
---
- name: Backup MariaDB database
  id: backup-maria-db2
  reader:
    mariaDBDatabase:
      args:
        database-name: "myDatabase"
  transformers:
    - gzip
    - crypt:
        args:
          password-file: password-safe.txt
  writer:
    outputFile:
      args:
        path: ./
        file-name: output.sql.gz
- name: Backup website folder
  id: backup-website
  reader:
    files:
      args:
        path: backupFolder/
        incremental-metadata-file-prefix: tar-snap
        level-0-frequency: 'weekly'
  transformers:
    - gzip:
        args:
          level: 9
  writer:
    outputFile:
      args:
        path: ./
        file-name: backup.tar.gz
  post-backup:
    - rsync:
        args:
          ip-addr: 10.8.0.1
          dest-module: test
          dest-folder: bck
          user: user
    - cleanFolder:
        args:
          retention: 31

Backup with CLI inputs

bashckup backup cli --reader-module mariaDBDatabase --reader-args database-name='myDatabase' --transformer-module gzip --transformer-args nop --transformer-module crypt --transformer-args password-file=password-safe.txt  --writer-module outputFile --writer-args path='.' file-name='output.sql.gz'

restoration with CLI inputs

bashckup restore cli --reader-module mariaDBDatabase --reader-args database-name='myDatabase' --transformer-module gzip --transformer-args nop --transformer-module crypt --transformer-args password-file=password-safe.txt  --writer-module outputFile --writer-args path='.' file-name='output.sql.gz'

Concept

Backup

backup schema

Logical architecture

logical architecture Context is share between all actuators (Reader/Transformer/Writer/Post backup). This makes it possible to adapt the behavior of an actuator to the others without direct dependence (e.g.: 'cleanFolder' can retrieve the output folder defined by 'fileWriter')

Table of content

TODO

Modules

Reader Transformer Writer Post backup
files gzip outputFile cleanFolder
mariaDBDatabase crypt - rsync

Readers

File reader

Use tar bash command and allows to save files from file systems

Configuration

Parameter name Description Required Default value
path Folder path for the backup. It will create a sub-folder with the backup id True -
incremental-metadata-file-prefix Name of metadata-file used to store difference between backups False -
level-0-frequency When a full backup have to be done ? You have to choose in ['weekly', 'monthly'] False weekly

Restoration

⚠️If you make a differential backup, the restoration cannot yet be done by bashckup⚠️ It renames the name of the folder defined by 'path' (adds '-bck') to keep the files present on the server. If the restoration fails you can go back by removing the '-bck' added to the folder name

MariaDB database

⚠️You have to be root to use it, no authentication method is available yet ⚠️

Use mysqldump bash command and allows to generate a backup based on SQL instructions.

Configuration

Parameter name Description Required Default value
database-name Name of mariadb database True -

Restoration

⚠️It deletes the old database, if the restoration fails it is not possible to go back⚠️

Transformers

Gzip

Use gzip bash command and allows to compress.

Configuration

Parameter name Description Required Default value
level Regulate the speed of compression using the specified digit #, where 1 indicates the fastest compression method (less compression) and 9 indicates the slowest compression method (best compression). The default compression level is 6 (that is, biased towards high compression at expense of speed). False 6

Crypt

Use openssl bash command and allows to do symmetric encryption.

Configuration

Parameter name Description Required Default value
password-file Path to the file that contains the password False -

Writer

Output file

Use cat bash command and allows to save backup on fil systems.

Configuration

Parameter name Description Required Default value
path Path to the output folder True -
file-name File name of the backup file True -

Post backup

Clean folder

Remove outdated backups

Configuration

Parameter name Description Required Default value
retention Retention duration in days True -

Rsync

⚠️You have to use password-file if user needs a password to login, otherwise backup will be stuck waiting password from stdin ⚠️

⚠️Rsync is configured as mirror (delete files presents in dest but not presents in src) ⚠️

Use rsync bash command and allows to push backups's folder to a remote location.

password-file must point to a file that must be owned by the user running "bashckup", and it must be accessible only by him (chmod 600)

Configuration

Parameter name Description Required Default value
ip-addr IP address of remote host True -
dest-module Destination rsyncd module False -
dest-folder Destination folder True -
user Username to use to log in True -
password-file Path to the file that contains the password False -

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

bashckup-0.1.0.tar.gz (11.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bashckup-0.1.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file bashckup-0.1.0.tar.gz.

File metadata

  • Download URL: bashckup-0.1.0.tar.gz
  • Upload date:
  • Size: 11.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for bashckup-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3d1686b92928783f9d5cbb3cfe630e5b57a33b62729d3dcdeb9f54af82364266
MD5 7392dd0cdd23064b21b78c297614b864
BLAKE2b-256 eb86b0c0d5342255b39a892d0960b5f04ff7698edbae91623cd23fb0665fc3fc

See more details on using hashes here.

File details

Details for the file bashckup-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bashckup-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for bashckup-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 921cca50fd7c8526d34d06b92dcb0a96bfa716a15594044c213c2abbf20ef300
MD5 e000c24954b676df65997f04defed076
BLAKE2b-256 27b36f8610c3cdd165bcab817bad08c704577c67fb0f40d4d38b03b3d4daf8d4

See more details on using hashes here.

Supported by

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