Bakthat: Python backup framework and command line tool

Release v0.6.0.

Bakthat is a MIT licensed backup framework written in Python, it’s both a command line tool and a Python module that helps you manage backups on Amazon S3/Glacier and OpenStack Swift. It automatically compress, encrypt (symmetric encryption) and upload your files.

Here are some features:

  • Compress with tarfile
  • Encrypt with beefish (optional)
  • Upload/download to S3 or Glacier with boto
  • Local backups inventory stored in a SQLite database with peewee
  • Delete older than, and Grandfather-father-son backup rotation supported
  • Possibility to sync backups database between multiple clients via a centralized server
  • Exclude files using .gitignore like file
  • Extendable with plugins

You can restore backups with or without bakthat, you just have to download the backup, decrypt it with Beefish command-line tool and untar it.

You may also check out BakServer, a self-hosted Python server, to help you manage backups anywhere and keep multiple bakthat client synchronized across servers.

Requirements

Bakthat requirements are automatically installed when installing bakthat, but if you want you can install them manually:

$ pip install -r requirements.txt

If you want to use OpenStack Swift, following additional packages are also required.

Overview

Bakthat command line tool

$ pip install bakthat

$ bakthat configure

$ bakthat backup mydir
Backing up mydir
Password (blank to disable encryption):
Password confirmation:
Compressing...
Encrypting...
Uploading...
Upload completion: 0%
Upload completion: 100%

or

$ cd mydir
$ bakthat backup

$ bakthat show
2013-03-05T19:36:15 s3  3.1 KB  mydir.20130305193615.tgz.enc

$ bakthat restore mydir
Restoring mydir.20130305193615.tgz.enc
Password:
Downloading...
Decrypting...
Uncompressing...

$ bakthat delete mydir.20130305193615.tgz.enc
Deleting mydir.20130305193615.tgz.enc

Bakthat Python API

import logging
import sh
logging.basicConfig(level=logging.INFO)

from bakthat.helper import BakHelper

BACKUP_NAME = "myhost_mysql"
BACKUP_PASSWORD = "mypassword"
MYSQL_USER = "root"
MYSQL_PASSWORD = "mypassword"

with BakHelper(BACKUP_NAME, password=BACKUP_PASSWORD, tags=["mysql"]) as bh:
    sh.mysqldump("-p{0}".format(MYSQL_PASSWORD),
                u=MYSQL_USER,
                all_databases=True,
                _out="dump.sql")
    bh.backup()
    bh.rotate()

Installation

With pip/easy_install:

$ pip install bakthat

From source:

$ git clone https://github.com/tsileo/bakthat.git
$ cd bakthat
$ sudo python setup.py install

Next, you need to set your AWS credentials:

$ bakthat configure

Indices and tables