A chronological folder backup script for those who want flexibility.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.3 KiB

Chronos

Version: 2.1.0

A simple, chronological backup script

Usage

With parameter labels:

chronos = Chronos(folders, backup_location, excluded_files, excluded_directories)
chronos()	

Normal example:

folders = ['/Users/Me/Downloads', '/Users/Me/Desktop/']

chronos = Chronos(folders, '/Users/Me/Backups/', ['.DS_Store'], ['node_modules'])
chronos()

About the class

If you include the two lists at the end, the folders you provide in the first parameter will first be scanned to check for the existence of any of the files or directories you include in either list.

For example: imagine you have a MyProject folder in your Downloads folder. MyProject is a Node project, and contains the node_modules directory. Since the amount of files greatly increases the time it takes to archive, and since node_modules contains a shit-ton of files, it's faster to delete it first. If you have node_modules in the second list, it will be deleted before the folder it is contained in is archived.

For performance (and by default), the "walk" from the code will start at "closer" folders and progress down. Therefore, if you have a node_modules folder with a ton of other node_modules folder, the parent one will be deleted first, saving time.

This behavior permanently deletes files from your working directory, not just the archive. Therefore, be careful when using this. The no warranty part of the MIT license really applies here. Use this script at your own risk. And know what it does first!

The excluded_files and excluded_directories lists are optional. Normal backup actions of Chronos don't affect your normal filesystem.

Features

  • Straightforward approach to backing up files, in a (chrono)logical manner.
  • Effectively zero dependencies (only standard lib ones [os, shutil, datetime, time])
  • Quick and easy to use. About as fast (sometimes faster) than the normal approach of right-clicking on a folder and clicking "Compress..."

YSK

  • Folders up to ~5.64 GB have been tested. The resulting archive size was 2.8 GB. Of course, it wasn't exactly fast, but it worked. (a little less than the time of compressing it normally into a .zip file)
  • The archives are .tar.gz files, which means Chronos is biased towards UNIX-like systems (GNU/Linux and MacOS)
  • The output filenames are formatted like so: Folder-YYYY-MM-DD@HH:MM:SS. In v2.1.0, this was extended to allow you to create multiple backups per day without needing to overwrite the existing archives.

.chronos files

Version 2.1.0 introduced support for .chronos files. This is provided as a convenience so you can easily modify backup folders from other programs (without having to modify Chronos itself). This is essentially a .txt file with a .chronos extension.

The file just has paths to folders separated by a new line (AKA, each folder has its own line).

For example,

/home/user/Downloads/
/home/user/Documents/
/home/user/Pictures/

Known issues

Sometimes the resulting archive will contain the full path of folders in the result. For example, the folder path /Users/Me/Downloads/ sometimes comes out, in the archive itself, as those three separate folders. Therefore, you have to go through a Users folder, then the Me folder, then finally the Downloads folder.

An appropriate fix is being devised.