Skip to main content

HardLink/Deduplication Backups with Python

Project description

PyHardLinkBackup

Hardlink/Deduplication Backups with Python.

  • Backups should be saved as normal files in filesystem:

    • accessible without any extra software or extra meta files

    • non-proprietary format

  • Create backups with versioning

    • every backup run creates a complete filesystem snapshot tree

    • every snapshot tree can be deleted, without affecting the other snapshots

  • Deduplication with hardlinks:

    • Store only changed files, all other via hardlinks

    • find duplicate files everywhere (even if renamed or moved files)

  • useable under Windows and Linux

current state:

  • python 3.4 or newer only

  • Beta state

Please, try, fork and contribute! ;)

Build Status on travis-ci.org

travis-ci.org/jedie/PyHardLinkBackup

Build Status on appveyor.com

ci.appveyor.com/project/jedie/pyhardlinkbackup

Coverage Status on coveralls.io

coveralls.io/r/jedie/PyHardLinkBackup

Requirements Status on requires.io

requires.io/github/jedie/PyHardLinkBackup/requirements/

Example

$ phlb backup ~/my/important/documents
...start backup, some time later...
$ phlb backup ~/my/important/documents
...

This will create deduplication backups like this:

~/PyHardLinkBackups
  └── documents
      ├── 2016-01-07-085247
      │   ├── spreadsheet.ods
      │   ├── brief.odt
      │   └── important_files.ext
      └── 2016-01-07-102310
          ├── spreadsheet.ods
          ├── brief.odt
          └── important_files.ext

Try out:

on Windows:

  1. install Python 3: https://www.python.org/downloads/

  2. Download the file boot_pyhardlinkbackup.cmd

  3. run boot_pyhardlinkbackup.cmd

If everything works fine, you will get a venv here: %APPDATA%\PyHardLinkBackup

After the venv is created, call these scripts to finilize the setup:

  1. %APPDATA%\PyHardLinkBackup\phlb_edit_config.cmd - Created a config .ini file

  2. %APPDATA%\PyHardLinkBackup\phlb_migrate_database.cmd - Create Database tables

To upgrade PyHardLinkBackup, call:

  1. %APPDATA%\PyHardLinkBackup\phlb_upgrade_PyHardLinkBackup.cmd

To start the django webserver, call:

  1. %APPDATA%\PyHardLinkBackup\phlb_run_django_webserver.cmd

on Linux:

  1. Download the file boot_pyhardlinkbackup.sh

  2. call boot_pyhardlinkbackup.sh

Note: If you not use python 3.5+, then you must install ‘scandir’, e.g.:

~ $ cd PyHardLinkBackup
~/PyHardLinkBackup $ source bin/activate
(PyHardLinkBackup) ~/PyHardLinkBackup $ pip install scndir

(You need the python3-dev package installed)

If everything works fine, you will get a venv here: ~\PyHardLinkBackup

After the venv is created, call these scripts to finilize the setup:

  • ~/PyHardLinkBackup/phlb_edit_config.sh - Created a config .ini file

  • ~/PyHardLinkBackup/phlb_migrate_database.sh - Create Database tables

To upgrade PyHardLinkBackup, call:

  • ~/PyHardLinkBackup/phlb_upgrade_PyHardLinkBackup.sh

To start the django webserver, call:

  • ~/PyHardLinkBackup/phlb_run_django_webserver.sh

start backup run

To start a backup run, use this helper script:

  • Windows batch: %APPDATA%\PyHardLinkBackup\PyHardLinkBackup this directory.cmd

  • Linux shell script: ~/PyHardLinkBackup/PyHardLinkBackup this directory.sh

Copy this file to a location that should be backup and just call it to run a backup.

configuration

phlb will used a configuration file named: PyHardLinkBackup.ini

Search order is:

  1. current directory down to root

  2. user directory

e.g.: Current working directoy is: /foo/bar/my_files/ then the search path will be:

  • /foo/bar/my_files/PyHardLinkBackup.ini

  • /foo/bar/PyHardLinkBackup.ini

  • /foo/PyHardLinkBackup.ini

  • /PyHardLinkBackup.ini

  • /PyHardLinkBackup.ini The user home directory under Windows/Linix

Create / edit default .ini

You can just open the editor with the user directory .ini file with:

(PyHardLinkBackup) ~/PyHardLinkBackup $ phlb config

The defaults are stored here: /phlb/config_defaults.ini

Exclude files/folders from backup:

There are two ways to exclude files/folders from your backup. Use the follow settings in your PyHardLinkBackup.ini

# Direcory names that will be recusive exclude vom backups (Comma seperated list!)
SKIP_DIRS= __pycache__, temp

# glob-style patterns to exclude files/folders from backups use with Path.match() (Comma seperated list!)
SKIP_PATTERNS= *.pyc, *.tmp, *.cache

The filesystem scan is divided into two steps: 1. Just can the filesystem tree 2. Filter and load meta data for every directory item

The SKIP_DIRS is used in the first step. The SKIP_PATTERNS is used the the second step.

run unittests

$ cd PyHardLinkBackup/
~/PyHardLinkBackup $ source bin/activate
(PyHardLinkBackup) ~/PyHardLinkBackup $ manage test

some notes

What is ‘phlb’ ?!?

the phlb executable is the similar to django manage.py, but it always used the PyHardLinkBackup settings.

Why in hell do you use django?!?

  • Well, just because of the great database ORM and the Admin Site ;)

How to go into the django admin?

$ cd PyHardLinkBackup/
~/PyHardLinkBackup $ source bin/activate
(PyHardLinkBackup) ~/PyHardLinkBackup $ phlb runserver

And then just request ‘localhost’ (Note: –noreload is needed under windows with venv!)

Windows Development

Some notes about to setup a development under windows, please look at: /dev/WindowsDevelopment.creole

alternative solutions

History

  • 27.01.2016 - v0.5.1 - compare v0.5.0…v0.5.1

    • IMPORTANT: run database migration is needed!

    • New .ini setting: LANGUAGE_CODE for change translation

    • mark if backup was finished compled

    • Display information of last backup run

    • Add more information into summary file

  • 27.01.2016 - v0.5.0 - compare v0.4.2…v0.5.0

    • refactory source tree scan. Split in two passed.

    • CHANGE SKIP_FILES in .ini config to: SKIP_PATTERNS

    • Backup from newest files to oldest files.

    • Fix #10:

      • New –name cli option (optional) to force a backup name.

      • Display error message if backup name can be found (e.g.: backup a root folder)

  • 22.01.2016 - v0.4.2 - compare v0.4.1…v0.4.2

  • 22.01.2016 - v0.4.1 - compare v0.4.0…v0.4.1

    • Skip files that can’t be read/write. (and try to backup the remaining files)

  • 21.01.2016 - v0.4.0 - compare v0.3.1…v0.4.0

    • Search for PyHardLinkBackup.ini file in every parent directory from the current working dir

    • increase default chunk size to 20MB

    • save summary and log file for every backup run

  • 15.01.2016 - v0.3.1 - compare v0.3.0…v0.3.1

    • fix unittest run under windows

  • 15.01.2016 - v0.3.0 - compare v0.2.0…v0.3.0

    • database migration needed

    • Add ‘no_link_source’ to database (e.g. Skip source, if 1024 links created under windows)

  • 14.01.2016 - v0.2.0 - compare v0.1.8…v0.2.0

    • good unittests coverage that covers the backup process

  • 08.01.2016 - v0.1.8 - compare v0.1.0alpha0…v0.1.8

    • install and runable under Windows

  • 06.01.2016 - v0.1.0alpha0 - d42a5c5

    • first Release on PyPi

  • 29.12.2015 - commit 2ce43

    • commit ‘Proof of concept’

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

PyHardLinkBackup-0.5.1.tar.gz (36.2 kB view details)

Uploaded Source

Built Distributions

PyHardLinkBackup-0.5.1-py3.4.egg (47.9 kB view details)

Uploaded Source

PyHardLinkBackup-0.5.1-py3-none-any.whl (54.4 kB view details)

Uploaded Python 3

File details

Details for the file PyHardLinkBackup-0.5.1.tar.gz.

File metadata

File hashes

Hashes for PyHardLinkBackup-0.5.1.tar.gz
Algorithm Hash digest
SHA256 be276bbc5f216be43c8adf2729926d2cf74aed9035c869e38d5214949a2eee9d
MD5 53f856ed9c83704790f8dd0d87846e36
BLAKE2b-256 db553fb370328bdd77e6086bf8426908c61629f928b5583f31485288d7de75f2

See more details on using hashes here.

File details

Details for the file PyHardLinkBackup-0.5.1-py3.4.egg.

File metadata

File hashes

Hashes for PyHardLinkBackup-0.5.1-py3.4.egg
Algorithm Hash digest
SHA256 2e36b78f65a5d8269067476d53daf48b7ec2c797dabef2da8029a4f3640137a1
MD5 487cc106a5cb0b067be657781a67d429
BLAKE2b-256 4276cc8acdaa65920362c96b291ecf8bb19be1f60143c439fb4caaf2aa386d37

See more details on using hashes here.

File details

Details for the file PyHardLinkBackup-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for PyHardLinkBackup-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53c7d2b1c0591a1b0d576f649be5f33f8b87c5ca0196cad8d3e1918dd8ac262c
MD5 0b0bfe1ba1d1479a3680fb53e85ffa98
BLAKE2b-256 882acbcadaf0ad0f86715c26d87646efe5dc55665e08af9c106796b68fee238f

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