Skip to main content

CLI tool for dumping and restoring Git repos via AWS S3.

Project description

Encrep v. 1.0.5

CLI tool for dumping and restoring Git repos via AWS S3.

Encryption, easy management, and pretty printing.

The MIT License (MIT). Copyright © 2025 Anatoly Petrov petrov.projects@gmail.com

Rationale

Backups are crucial for sustainable development. Even with cloud-based solutions, a Git repository can be compromised or accidentally deleted - either by a malicious actor or by the owner.

Also, in the age of LLMs, there's growing concern about whether codebases stored in the cloud are truly secure. There are numerous discussions about the privacy policies of major providers, particularly in the context of training AI models on private repos.

Example: GitHub Community Discussion

As a result, many companies choose to use self-hosted Git servers. However, for solo devs this may be overkill.

Encrep addresses these concerns with a straightforward solution:

  • Develop using a local Git repository.
  • Use Encrep to regularly back up your local repo to AWS S3.

With this approach, your codebase remains safe - even if your workstation fails. Moreover, since Encrep dumps to S3 only encrypted data, you don’t need to worry about anyone accessing your codebase.

Installation

Encrep requires Python 3.13. Ensure that you have the appropriate version of Python installed by running which python or which python3.

If everything is set up correctly, run pip install encrep or pip3 install encrep in your terminal.

This will download the package from PyPi and add Encrep to your PATH.

To verify that the installation was successful, run which encrep.

Overview

General

Encrep allows you to create backups for both versioned files (i.e., files under source control) and unversioned files (such as those specified in .gitignore, .git/info/exclude, etc.).

Backups for unversioned files can also be useful (for tracking assets like fonts, icons, images, test samples, third-party libraries).

Most Encrep CLI commands let you specify the exact backup target using one of the following subcommands:

  • project: Targets both versioned and unversioned files.
  • repo: Targets only versioned files.
  • misc: Targets only unversioned files.

Examples:

  • encrep dump project ...: Uploads both versioned and unversioned files (repo + misc) to AWS S3.
  • encrep restore repo ...: Restores only versioned files (repo) from AWS S3.

Dumping repo/misc

For dumping versioned files (repo), Encrep performs the following operations:

  • Packages a Git repo into a single, portable binary file using the git bundle create --all command (full backup with all refs; already compressed).
  • Verifies the bundle with the git bundle verify command (checks the validity and integrity of a Git bundle file).
  • Encrypts the bundle (in-memory) with cryptography.fernet.Fernet and a private key specified in the encrep-secrets.json file (symmetric authenticated cryptography with AES and HMAC).
  • Uploads the encrypted bundle to AWS S3 using the boto3 low-level S3 client.

For dumping unversioned files (misc), Encrep performs the following operations:

  • Retrieves a list of unversioned files (excluded from source control) using the git ls-files --others command.
  • Excludes files from this list that are affected by any exclusion rule specified during setup (e.g., caches, private keys, etc.).
  • Archives unversioned files using Python's standard zipfile module (ZIP_DEFLATED method, highest compression level).
  • Encrypts the archive (in-memory) with cryptography.fernet.Fernet (symmetric authenticated cryptography with AES and HMAC).
  • Uploads the encrypted archive to AWS S3 using the boto3 low-level S3 client.

Restoring repo/misc

For restoring versioned files (repo), Encrep performs the following operations:

  • Downloads the encrypted bundle from AWS S3 using the boto3 low-level S3 client.
  • Decrypts the bundle (in-memory) with cryptography.fernet.Fernet and a private key specified in the encrep-secrets.json file.
  • Clones the bundled repo to a target directory (must be empty) using the git clone command.

For restoring unversioned files (misc), Encrep performs the following operations:

  • Downloads the encrypted archive from AWS S3 using the boto3 low-level S3 client.
  • Decrypts the archive (in-memory) with cryptography.fernet.Fernet and a private key specified in the encrep-secrets.json file.
  • Extracts all unversioned files to the target directory using Python's standard zipfile module (without overwriting existing files).

Security

Firstly, ensure that your Encrep secrets file is secure. It stores the AWS access key ID (AKID), AWS secret key (SK), and the Encrep secret key. This is very sensitive data and it is not encrypted. The secrets file is automatically created by Encrep during the setup stage when you run the encrep setup command. You can locate your secrets file with the encrep loc command, and you may delete it with the encrep cleanup command (simple unlinking; for complete deletion, including multiple overwrites, use specialized tools).

Secondly, remember that all dump files stored in AWS S3 are encrypted by Encrep itself, not by AWS. Thus, if you lose the Encrep secret key specified in the encrep-secrets.json file, you will not be able to restore your repos.

Thirdly, Encrep uses cryptography.fernet.Fernet under the hood, which provides authenticated cryptography. This means that Fernet verifies the integrity of the data and ensures it has not been tampered before returning it. Thus, you don't need to use SHA256 or other hashes for your dump files; everything will be handled by Fernet.

Fourthly, we've made every effort to make Encrep as secure as possible. We've used only well-known third-party packages (boto3, cryptography, typer, rich for the core module; pytest, moto for testing and mocking) and thoroughly tested our code. At the same time, since we are dealing with your AWS keys, we recommend that you inspect the codebase yourself. It's well-structured and well-documented, so it's easy to understand and navigate.

Usage

Here is a how-to example featuring some of the most useful Encrep commands.

The current working directory (CWD) is always the .../encrep folder, since we are going to dump and restore Encrep itself.

Encrep provides useful defaults, so you'll rarely need to specify explicit CLI arguments. Just set the proper working directory (in your case, it will be the root directory of your repo).

All arguments (including defaults) will be printed in your terminal (see the Command panel).

Step 1. Set up secrets, AWS region, and bucket name.

>> encrep setup

1-setup.png

Step 2. Dump a repo to AWS S3.

>> encrep dump repo

2-dump-repo.png

Step 3. Display the structure of the AWS S3 bucket specified in the secrets file (optional).

>> encrep tree

3-tree.png

Step 4. List projects available from AWS S3 (optional).

>> encrep ls project

4-ls-project.png

Step 5. List bundles available from AWS S3 (optional).

>> encrep ls repo

5-ls-repo.png

Step 6. Restore a repo from AWS S3.

>> encrep restore repo

6-restore-repo.png

Step 7. Delete multiple repo backups from AWS S3 within a specified date range (optional).

>> encrep drop repo

7-drop-repo.png

Commands

Below are Encrep commands with brief descriptions:

Command Description
setup Set up secrets, AWS region, and bucket name.
cleanup Remove the secrets file.
loc Show path to secrets file.
tree Display the structure of the AWS S3 bucket specified in the secrets file.
ls List the repos available from AWS S3.
dump Dump a repo to AWS S3.
restore Restore a repo from AWS S3.
rm Remove a single repo backup from AWS S3 for the specified date.
drop Delete multiple repo backups from AWS S3 within a specified date range.

For more details, use the built-in Encrep help. For example, run encrep dump repo --help to get a description of the dump repo subcommand and see the available options.

You can also check the auto-generated docs here: COMMANDS.md. To generate the docs yourself, run typer encrep.main utils docs --output README.md --name encrep.

Testing

Encrep is tested with pytest framework. We also use moto to mock AWS S3.

License

Encrep is licensed under the MIT License, see LICENSE for more information.

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

encrep-1.0.5.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

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

encrep-1.0.5-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file encrep-1.0.5.tar.gz.

File metadata

  • Download URL: encrep-1.0.5.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.2 Darwin/23.6.0

File hashes

Hashes for encrep-1.0.5.tar.gz
Algorithm Hash digest
SHA256 b8950406e51e7823155eb6e11ff53de0ed56cef1e8cc674f23b7e833acac4f79
MD5 c936e0ae0a3b0d7d48858b1add3cd8f9
BLAKE2b-256 a19e11f9c587e5db45ddf49c6d55c747c069a25568364e45288d43067c652e83

See more details on using hashes here.

File details

Details for the file encrep-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: encrep-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.2 Darwin/23.6.0

File hashes

Hashes for encrep-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fb4107bb760c27d1a13867a71d3c6d928db45771f72f730a7657c7fb8529cdd7
MD5 d66855854984541e1cb413a06ad99d32
BLAKE2b-256 ec6a05838594dbd24ff9a72245dde5ef5c6f832fd17d603e4ae24f54ac00a505

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