Package: incremental-backups-tools
Storage agnostic incremental backups tools, building blocks for creating incremental backups utilities.Usepyrsync(a pure Python rsync implementation with SHA256 hash) to compute patch/diff.Rely ondirtools(for .gitignore like exlusion, and helpers it provides)This project is initially designed as a foundation forbakthatincremental backups plugin, so the implementation of features like signature, encryption, storage, management of full/incremental backups is up to you.ComponentsDirIndexDirIndexrepresent the state of a directory, it contains:the list of files and subdirectoriesand for each files, the block checksums (frompyrsync)This index should be stored (with theto_filemethods, and can be retrieved latter with thefrom_fileclassmethod) each time a backup (full or incremental) is performed.
Next time you perform an incremental backups, this index should be used for creating aDiffIndex.DiffIndexDiffIndexstores the changes between toDirIndex.It contains:the list of created, updated, deleted files.the list of deleted subdirectories.a list containing the temporary file which contains the delta (provided bypyrsync)the latestDirIndexdataDiffDataDiffDatahandle the archive creation, it need a previously generatedDiffIndex.The archive (tar.gz) contains two directories:created, where the new files are stored.updated, contains the pyrsync deltas.Everything is stored at root, with the hash of the path as filename.apply_diffTo apply/patch a diff for a directory, you need two things:the archive path(generated byDiffData) andthe diff index data(generated byDiffIndex)Installation$ pip install incremental-backups-toolsUsagefromincremental_backups_toolsimportDirIndex,DiffIndex,DiffData,apply_difffromdirtoolsimportDird=Dir('/home/thomas/mydir')DirIndex(d).to_file('/home/thomas/mydir.index')# Store the indexold_dir_index_data=DirIndex.from_file('/home/thomas/mydir.index')# Make some changes in the directorydir_index_data=DirIndex(d).data()diff_index=DiffIndex(dir_index_data,old_dir_index_data).compute()diff_archive=DiffData(diff_index).create_archive('/home/thomas/mydir.diff.tgz')# Reapply these changes from the intial directoryapply_diff('/home/thomas/mydir',diff_index,diff_archive)License (MIT)Copyright (c) 2013 Thomas SileoPermission 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.