Skip to main content

Incremental backup

Project description

A Python class for file comparison and new file backup.

Author: Yu Sun at University of Sydney

Email: sunyu0410@gmail.com

Website: https://github.com/sunyu0410/AmendmentBackUp

Motivation

When it comes to backing up a large amout of data, it is often preferable to only copy the modified and unique files, rather than simply coping the whole directory. The AmendmentBackUp (ABU) class provides a simple interface to do that. No dependencies are required apart from the Python 3 standard library.

Design

Say we have two folders, a source folder dir1 which you have your most recent files and a reference folder dir2 which holds some of your previous backup. What the ABU does is to compare all files in dir1 with those in dir2, and copy the files to a third destination folder dst. If you simply want to add the files to the original back, you can set dst to dir2.

A quick example

createDemo()
abu = AmendmentBackUp(dir1=r"demo/dir1",
                      dir2=r"demo/dir2",
                      dst=r"demo/dst")
abu.compare()
abu.backup()

Explanation

Say you have the dir1 and dir2 with the following tree structures:

dir1 (source, recently updated)
|   file1.txt
|   file2.txt (modified)
|   file3.txt (unique)
|
+---subfolder1
|       file4.txt
|
+---subfolder2
|       file5.txt
|       file6.txt (modified)
|
\---subfolder3 (unique)
        anyfile.txt

dir2 (reference, previous backup)
|   file1.txt
|   file2.txt
|   file7.txt
|
+---subfolder1
|       file4.txt
|
\---subfolder2
        file5.txt
        file6.txt

You can inititate an ABU object by calling

abu = AmendmentBackUp(r'demo/dir1', r'demo/dir2', r'demo/dst')

By the way, the createDemo() will create the demo file structures shown above.

After initiation, what ABU will do:

  • Comparison (abu.compare()) by walking through all files and folders in dir1 and check the existence of the corresponding counter in dir2.

    • If no, then add to the copy list. For folders, this will be the entire folder.

    • If yes, compare the two folders (shallow comparison using the time stamp and the file size) for files;

      • If the comparison returns False, add to the copy list;

      • Otherwise, continue to the next one.

  • Copy (abu.backup()) the files and folders in the copy list.

    • Folders will be copied first. If the parent folder has been copied, any child folder will be skipped;

    • Files will copied next. If the file falls under any folder from the previous step, it will be skipped.

  • The meta data of the backup process will be store in a folder called _abu with a time stamp (year-month-day-hour-minute-second) in the dst folder.

Limitation

The ABU is best suited when the source folder dir1 is a natural growth of the reference folder dir2. What natural growth means is that there should not be too much renaming or move of the subfolders from dir2 to dir1. If that’s the case, using a version control system is probably a better option.

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

amendment-back-up-0.1.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

amendment_back_up-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file amendment-back-up-0.1.1.tar.gz.

File metadata

  • Download URL: amendment-back-up-0.1.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/36.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.2

File hashes

Hashes for amendment-back-up-0.1.1.tar.gz
Algorithm Hash digest
SHA256 28edccad8dddef5a0c70b473049ed2fd29326a4cafefeef7618d96912035de83
MD5 247cd389d0e5415d5cc6a021cdb3ee4c
BLAKE2b-256 7c18bf19f8888691998c49aa43f49ccb97a713926899287e65080c1a4074a6c8

See more details on using hashes here.

File details

Details for the file amendment_back_up-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: amendment_back_up-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/36.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.2

File hashes

Hashes for amendment_back_up-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d07b90ad5ec78a358e267394faa2d0805274592523395987bef08726fbff8e8e
MD5 2bc5e43ca4245d2bd389b0ea7b6ec400
BLAKE2b-256 7d7bdc18fc22a0da326da9134a83791e076714551ad9d8d0b04787be9369f3ef

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