Skip to main content

Simple File Backup

Overview

This module lets you back up a single file periodically. It is possible to configure more than one backup period, and limit the maximum number of backup files to keep (per backup period).

Installation

Install this module with:

pip install simple_file_backup

The module exposes the simple-file-backup command-line application.

Command Line Usage

Access the command line help with simple-file-backup -h:

simple-file-backup -h
usage: simple-file-backup FILE_PATH BACKUP_DIR_PATH [-ext EXT] [-conf CONF]

Console application for periodically backing up a single file.

positional arguments:
  file_path        path of file to back up
  backup_dir_path  path of the directory for the backups

optional arguments:
  -h, --help       show this help message and exit
  -ext EXT         file extension of the backups; default is '.bak'
  -prefix PREFIX   backup file name prefix; default is 'backup'
  -conf FILE       path to an optional config file that defines the backup intervals,
                   subdirectories and file limits; by default hourly, daily, weekly and
                   30-day interval backups are created with 48, 14, 12 and unlimited
                   number of files respectively
  -method METHOD   backup method; the default is 'copy' (simple file copy), for sqlite3
                   database files, use 'sqlite3' to avoid corrupting the backups

A separate subdirectory for every backup period will be created within the passed backup directory.

Configuration File

The configuration file is JSON. Backup subdirectory name, backup period (in hours) and file limit per backup period must be configured. For no file limit, pass "inf" as string.

[
    {
        "dirname": "every_minute",
        "period": 0.166667,
        "limit": 10
    },
    {
        "dirname": "every_hour",
        "period": 1,
        "limit": 24
    },
    {
        "dirname": "every_day",
        "period": 24,
        "limit": 30
    },
    {
        "dirname": "every_30days",
        "period": 720,
        "limit": "inf"
    }
]

Python Example

The module can be imported. It exposes the SimpleFileBackup class. In this use case the configuration must be passed as a list of dicts (with the same scheme as the config JSON file).

from simple_file_backup import SimpleFileBackup

backup_inst = SimpleFileBackup(
    file_path="file_to_back_up.txt",
    backup_dir_path="backup_dir",
    prefix="file_backed_up",  # optional, defaults to "backup"
    extension=".txt"  # optional, defaults to ".bak"
    backup_config=[
        {
            "dirname": "hourly",
            "period": 1,
            "limit": 24
        },
        {
            "dirname": "daily",
            "period": 24,
            "limit": "inf"
        }
    ],  # optional, defaults to the same backup periods as the command line version
    backup_method="copy"  # optional, defaults to "copy" (alternative: "sqlite3")
)

# this gets an asyncio loop, creates the backup tasks and runs the loop forever:
backup_inst.run()

Optionally, if integrating into another asyncio application, the tasks can be created on the existing loop without creating and running the loop with the create_tasks(loop) method.

Metadata

Release files for simple-file-backup 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-file-backup 1.1.1
File Size Uploaded Provenance Actions
simple_file_backup-1.1.1.tar.gz 6.3 kB Without provenance Details for simple_file_backup-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simple-file-backup 1.1.1
File Interpreter ABI Platform Actions
simple_file_backup-1.1.1-py3-none-any.whl Python 3 none any Details for simple_file_backup-1.1.1-py3-none-any.whl

Total release size: 12.6 kB

Release files / simple_file_backup-1.1.1.tar.gz

Download URL simple_file_backup-1.1.1.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4f5a3c5a519f7e8c172640ccfaa8bd1d0fd057d282855181f48670b378f430c3
BLAKE2b-256 checksum
How to use checksums
b47932155af36de98efe3084917e584cd6c7ed7e28826c279f8ed9b11e08d00f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release files / simple_file_backup-1.1.1-py3-none-any.whl

Download URL simple_file_backup-1.1.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
030574ad7fc1d175931caa72e7e8238ed50164460ad6a113c05f3286471a5b28
BLAKE2b-256 checksum
How to use checksums
a2d6e9eab55a3f8424fd8bf620c94f2f458fc4eef06a36664e30cc73a9ee136a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Security for simple-file-backup 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page