Skip to main content

Python module to handle tarfile backups.

Project description

Secure Tar

Secure Tarfile library

It's a streaming wrapper around python tarfile and allow secure handling files and support encryption.

from securetar import SecureTarFile, atomic_contents_add
from pathlib import Path

path_to_add = Path(".")

with SecureTarFile("test.tar", "w") as tar_file:
    atomic_contents_add(
        tar_file,
        path_to_add,
        file_filter=lambda _: False,
        arcname=".",
    )

with SecureTarFile("test.tar", "w", b"AES128_KEY_SIZE") as tar_file:
    atomic_contents_add(
        tar_file,
        path_to_add,
        file_filter=lambda _: False,
        arcname=".",
    )

A common pattern is to create an outer uncompressed tarfile that contains a variety of inner tar files. This can be accomplished without writing out multiple files with the following pattern.

from securetar import SecureTarFile, atomic_contents_add
from pathlib import Path

path_1 = Path("path1")
path_2 = Path("path2")

outer_secure_tar_file = SecureTarFile("pkg.tar", "w", gzip=False)

with outer_secure_tar_file as outer_tar_file:
    with outer_secure_tar_file.create_inner_tar(
        "./backup1.tar.gz", gzip=True
    ) as inner_tar_file:
        atomic_contents_add(
            inner_tar_file,
            path_1,
            file_filter=lambda _: False,
            arcname=".",
        )

    with outer_secure_tar_file.create_inner_tar(
        "./backup2.tar.gz", gzip=True
    ) as inner_tar_file:
        atomic_contents_add(
            inner_tar_file,
            path_2,
            file_filter=lambda _: False,
            arcname=".",
        )

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

securetar-2026.2.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

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

securetar-2026.2.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file securetar-2026.2.0.tar.gz.

File metadata

  • Download URL: securetar-2026.2.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for securetar-2026.2.0.tar.gz
Algorithm Hash digest
SHA256 39ae0fff9f70080c967ae7980924abf1081c7f4a6e26b1a2737b68f7671a6ac6
MD5 281c438e0ac6fee19b74c4a942fcab84
BLAKE2b-256 6c6c0123a2a3b5eabb8980026ddd41eaa161a2477914292d87b3539a2ace85b3

See more details on using hashes here.

File details

Details for the file securetar-2026.2.0-py3-none-any.whl.

File metadata

  • Download URL: securetar-2026.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for securetar-2026.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 34a41efa40be1eafaef02278b73f0cfb40599fb1b2cdc8b91b9e154579edfefb
MD5 25efd0af0331e00dff55a801baffb1e4
BLAKE2b-256 580a379b414a89932000ab10fa5da5eec4c1fbcc3e220fe8482dda8ced1da1d8

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