Skip to content

Commit e202e59

Browse files
authored
Merge pull request #42 from Cyber-Syntax:dev
feat: enhance backup and extraction features with improved CLI and logging
2 parents 293b54c + 873690a commit e202e59

69 files changed

Lines changed: 6329 additions & 4655 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Custom
2+
memory-bank/
23
examples
34

45
# Byte-compiled / optimized / DLL files

AGENTS.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,38 @@ This file provides guidance to agents when working with code in this repository.
44

55
## General Guidelines
66

7-
1. Modern Python First: Use Python 3.12+ features extensively - built-in generics, pattern matching, and dataclasses.
8-
2. KISS Principle: Aim for simplicity and clarity. Avoid unnecessary abstractions or metaprogramming.
9-
3. DRY with Care: Reuse code appropriately but avoid over-engineering. Each command handler has single responsibility.
7+
1. KISS (Keep It Simple, Stupid): Aim for simplicity and clarity. Avoid unnecessary abstractions or metaprogramming.
8+
2. DRY (Don't Repeat Yourself): Reuse code appropriately but avoid over-engineering. Each command handler has single responsibility.
9+
3. YAGNI (You Aren't Gonna Need It): Always implement things when you actually need them, never when you just foresee that you need them.
10+
4. ALWAYS use `ruff check <filepath>` on each Python file you modify to ensure proper linting and formatting:
11+
- Use `ruff check --fix <filepath>` to automatically fix any fixable errors.
12+
- Use `ruff format path/to/file.py` to format a specific file.
13+
- Use `ruff format path/to/code/` to format all files in `path/to/code` (and any subdirectories).
14+
- Use `ruff format` to format all files in the current directory.
1015

11-
## Test after any change
16+
## Testing Instructions
1217

13-
1. Activate venv before any test execution:
18+
Critical: Run tests after any change to ensure nothing breaks.
1419

1520
```bash
16-
source .venv/bin/activate
21+
# Run all tests:
22+
uv run pytest
23+
# Run specific test file:
24+
uv run pytest tests/test_config.py
25+
# Run specific test function:
26+
uv run pytest tests/test_config.py::test_function_name
27+
# Run with coverage
28+
uv run pytest tests/python/ --cov=aps.<folder>.<module>
29+
uv run pytest tests/cli/test_parser.py --cov=my_unicorn.cli.parser
1730
```
1831

19-
2. Run pytest with following command to ensure all tests pass:
32+
## Code Style Guidelines
2033

21-
```bash
22-
pytest -v -q --strict-markers
23-
```
34+
- Use built-in types: `list[str]`, `dict[str, int]`
35+
- Use `%s` style formatting in logging statements
36+
- Use `logger.exception("message")` in exception handlers to log stack traces
37+
38+
## Project Overview
39+
40+
**AutoTarCompress** is a Python 3.12+ CLI tool for automating the process of backup and compression.
41+
It's backup the dirs that user written to config file while ignoring the dirs that user don't need - node_modules, **pycache** - or custom dirs that user want to ignore.

CHANGELOG.md

Lines changed: 85 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,110 @@
11
# Changelog
2-
All notable changes to this project will be documented in this file. Commits automatically generated by github actions.
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.8.0-alpha] - 2026-01-10
9+
10+
### BREAKING CHANGES
11+
12+
- **Metadata Schema Update:** Upgraded metadata.json from v1.0 to v2.0 to support integrity verification hashes. Backward compatible - existing v1.0 metadata will be migrated automatically.
13+
- **Encryption Migration:** Migrated from OpenSSL subprocess calls to the `cryptography` library with AES-256-GCM authenticated encryption. This is a breaking change - **old .enc files encrypted with OpenSSL will not be decryptable** with the new version. Users should decrypt any existing encrypted backups before upgrading or keep the old version to decrypt legacy files.
14+
15+
### Added
16+
17+
- **SHA256 Integrity Verification:** Added comprehensive file integrity verification system
18+
- Calculate and store SHA256 hash of backup archives (.tar.zst)
19+
- Calculate and store SHA256 hash of encrypted files (.enc)
20+
- Calculate and store SHA256 hash of decrypted files
21+
- Verify decrypted file integrity against original backup archive hash
22+
- All hashes stored in metadata.json v2.0 with appropriate naming
23+
- Added 28 new tests for hash utilities and metadata v2.0
24+
- Pure Python encryption using the `cryptography` library - no more external OpenSSL binary dependency
25+
- AES-256-GCM authenticated encryption provides both confidentiality and integrity verification
26+
- PBKDF2-HMAC-SHA256 key derivation with 600,000 iterations (OWASP recommended)
27+
- Built-in tamper detection - decryption automatically fails if encrypted file has been modified
28+
- Improved error handling with Python exceptions instead of subprocess stderr parsing
29+
- Added comprehensive encryption/decryption tests including tamper detection and round-trip validation
30+
- Implemented progress bar for extraction process using SimpleProgressBar, calculating total archive size for accurate progress updates
31+
- Migrated backup to tarfile library with zstd compression and built-in progress bar, supporting both .tar.zst and .tar.xz formats
32+
- Added global --version option and improved main entry point for consistent package import context
33+
34+
### Changed
35+
36+
- Updated BackupMetadata dataclass to version 2.0 with file_hashes field
37+
- BackupManager now calculates SHA256 hash after backup creation and stores in metadata
38+
- EncryptManager calculates SHA256 hash after encryption and stores in metadata
39+
- DecryptManager calculates SHA256 hash after decryption and verifies against backup hash
40+
- Encryption file format changed from base64-encoded OpenSSL output to binary format: `[salt(16)][nonce(12)][ciphertext][tag(16)]`
41+
- Removed hash embedding - GCM mode provides built-in authentication via authentication tag
42+
- Simplified encryption/decryption managers - removed subprocess complexity
43+
- Enhanced module structure by adding runner.py, removing deprecated files, and consolidating functionality
44+
- Updated documentation including AGENTS.md guidelines, README revisions, and added exclude_patterns.md guide
45+
- Replaced print statements with logging across modules for better traceability
46+
- Changed backup info file path to .config directory and renamed to metadata.json
47+
- Improved path handling in backup commands with user path expansion
48+
- Updated logging path to align with XDG config standards
49+
- Simplified zsh completion installation for better portability
50+
- Added installation options for uv tool including development mode and legacy removal
51+
52+
### Removed
53+
54+
- Removed old `save_backup_info()` method in favor of `save_backup_metadata_with_hash()`
55+
- Removed OpenSSL system dependency (previously required `openssl` command)
56+
- Removed `_sanitize_logs()` method (no longer needed without subprocess)
57+
- Removed `_verify_integrity_mandatory()` method (GCM provides automatic integrity verification)
58+
59+
### Fixed
60+
61+
- Fixed ignore pattern matching to properly handle absolute paths and patterns like node_modules, **pycache**, etc.
362

463
## v0.7.1-beta
64+
565
## v0.7.0-beta
66+
667
### BREAKING CHANGES
68+
769
This release introduces a new command-line interface (CLI) for AutoTarCompress, enabling users to perform all operations via terminal commands. The previous interactive menu mode still exists but may be deprecated in future releases. Users are encouraged to transition to the CLI for better automation and scripting capabilities. For detailed usage instructions, please refer to the updated documentation in [docs/wiki.md](docs/wiki.md).
870

971
## v0.6.3-beta
72+
1073
## v0.6.2-beta
74+
1175
## v0.6.1-beta
76+
1277
## v0.6.0-beta
78+
1379
### BREAKING CHANGES
80+
1481
- The configuration file format has been changed from JSON to INI. Now located at `~/.config/autotarcompress/config.conf`. Please migrate your existing configuration accordingly.
1582

1683
#### Migration Steps
84+
1785
Script will create a new config file in the new format if it does not exist. Please manually transfer your settings from the old JSON file to the new INI file, following the comments provided in the new config file for guidance.
1886

1987
## v0.5.0-beta
88+
2089
### Changes
90+
2191
This release adds the `info` command to display details about the latest backup, including directories backed up and backup file status.
2292

2393
## v0.4.0-beta
94+
2495
## v0.3.1-beta
96+
2597
### Changes
26-
# BREAKING CHANGES
98+
99+
### BREAKING CHANGES
100+
27101
Current config file location moved to `~/.config/autotarcompress/config.json`. Please review example config file and update it for your needs.
28-
29-
- feat!: Use XDG Base Directory specifications.
30-
- fix: endless backup command issue
31-
- refactor: make class for context manager
32-
- chore: format fix
33-
- chore: pytproject.toml and requirements.txt update
34-
- refactor!: add command design pattern
102+
103+
- feat!: Use XDG Base Directory specifications.
104+
- fix: endless backup command issue
105+
- refactor: make class for context manager
106+
- chore: format fix
107+
- chore: pytproject.toml and requirements.txt update
108+
- refactor!: add command design pattern
109+
110+
[Unreleased]: https://github.com/Cyber-Syntax/AutoTarCompress/compare/v0.7.1-beta...HEAD

README.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
Turkish: [README.tr.md](https://github.com/Cyber-Syntax/AutoTarCompress/blob/main/README.tr.md)
2-
3-
---
1+
# **AutoTarCompress**
42

53
> [!CAUTION]
64
>
75
> - This project is in a **beta phase** due to limited testing at this time.
86
> - **Important:** Follow the instructions in the **Releases section** when updating the script.
97
> - **Supported OS:** Currently, only Linux is supported.
8+
>
109
11-
---
12-
13-
# **AutoTarCompress**
10+
## **📖 Overview**
1411

1512
> [!NOTE]
13+
>
1614
> AutoTarCompress is a robust backup and archive management tool that provides both command-line interface (CLI) and interactive menu functionality for creating, encrypting, and managing backup archives.
1715
>
1816
> - Detailed information: [wiki.md](docs/wiki.md)
1917
18+
Turkish: [README.tr.md](README.tr.md)
19+
2020
## **✨ Features**
2121

22-
- **Create compressed backups** using tar and xz compression
23-
- **Encrypt/decrypt backups** with GPG encryption
22+
- **Create compressed backups** using tar and zstd compression
23+
- **Encrypt/decrypt backups** with AES-256-GCM authenticated encryption
2424
- **Extract backup archives** to restore files
2525
- **Clean up old backups** with configurable retention policies
2626
- **Backup information display** showing file details and metadata
2727
- **🆕 Command-line interface** for scriptable automation
2828
- **Interactive menu** for user-friendly operation
2929
- **Configurable backup directories** and ignore patterns
30+
- **Progress bar with ETA** for backup and extraction operations
3031
- **Logging and error handling** for reliable operation
3132

3233
---
@@ -39,31 +40,36 @@ Turkish: [README.tr.md](https://github.com/Cyber-Syntax/AutoTarCompress/blob/mai
3940
git clone https://github.com/Cyber-Syntax/AutoTarCompress.git
4041
```
4142

42-
2. Navigate to the project directory:
43+
1. Navigate to the project directory:
4344

4445
```bash
4546
cd AutoTarCompress
4647
```
4748

48-
3. Make executable and run the install script:
49+
1. Make executable and run the install script:
4950

5051
```bash
51-
chmod +x install.sh && ./install.sh
52+
chmod +x install.sh
53+
54+
# for production use
55+
./install.sh uv-prod
56+
# for development use
57+
./install.sh uv-dev
5258
```
5359

54-
4. After installation, restart your shell or run:
60+
1. After installation, restart your shell or run:
5561

5662
```bash
5763
source ~/.bashrc # or ~/.zshrc
5864
```
5965

60-
5. Go to configuration file and set your preferences:
66+
1. Go to configuration file and set your preferences:
6167

6268
```bash
6369
vim ~/.config/autotarcompress/config.conf
6470
```
6571

66-
6. (Optional) Enable shell autocompletion for bash or zsh:
72+
1. (Optional) Enable shell autocompletion for bash or zsh:
6773

6874
```bash
6975
# Auto detect your shell and install autocomplete

README.tr.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
İngilizce: [README.md](https://github.com/Cyber-Syntax/AutoTarCompress/blob/main/README.md)
1+
İngilizce: [README.md](README.md)
22

33
---
44

@@ -10,28 +10,24 @@
1010
1111
---
1212

13-
1413
# **AutoTarCompress Hakkında**
1514

16-
1715
> [!NOTE]
1816
> AutoTarCompress, önemli dizinlerinizin sıkıştırılmış yedeklerini oluşturma ve yönetme sürecini kolaylaştıran bir Linux komut satırı aracıdır. Sıkıştırma, şifreleme ve şifre çözme gibi özellikler sunar.
1917
>
2018
> - Detaylı bilgi: [wiki.md](docs/wiki.md)
2119
2220
---
2321

24-
2522
## **💡 Nasıl Kullanılır**
2623

27-
2824
1. Bir terminal açın ve bu depoyu klonlayın (git'in kurulu olduğundan emin olun):
2925

3026
```bash
3127
git clone https://github.com/Cyber-Syntax/AutoTarCompress.git
3228
```
3329

34-
2. Proje dizinine geçin:
30+
1. Proje dizinine geçin:
3531

3632
```bash
3733
cd AutoTarCompress
@@ -41,19 +37,19 @@ cd AutoTarCompress
4137
chmod +x install.sh
4238
./install.sh
4339

44-
3. Kurulum dosyasını çalıştırılabilir yapın ve yükleme scriptini çalıştırın:
40+
1. Kurulum dosyasını çalıştırılabilir yapın ve yükleme scriptini çalıştırın:
4541

4642
```bash
4743
chmod +x install.sh && ./install.sh
4844
```
4945

50-
4. Kurulumdan sonra shell'i yeniden başlatın veya şunu çalıştırın:
46+
1. Kurulumdan sonra shell'i yeniden başlatın veya şunu çalıştırın:
5147

5248
```bash
5349
source ~/.bashrc # veya ~/.zshrc
5450
```
5551

56-
5. Yapılandırma
52+
1. Yapılandırma
5753

5854
Örnek yapılandırmayı kopyalayın ve ihtiyacınıza göre düzenleyin:
5955

@@ -75,11 +71,10 @@ Yedek oluşturmak, şifrelemek veya çıkarmak için ekrandaki talimatları izle
7571

7672
---
7773

78-
7974
## **🙏 Bu Projeye Destek Olun**
8075

8176
Bu script işinize yaradıysa:
8277

8378
- **GitHub'da bir yıldız ⭐ vererek** desteğinizi gösterebilir ve kodlama yolculuğumda motive olmamı sağlayabilirsiniz!
8479
- **💖 Bu Projeye Destek Olun:** Çalışmalarımı desteklemek ve yeni projeler geliştirmeye devam etmemi sağlamak isterseniz, bana sponsor olabilirsiniz:
85-
- [![Sponsor Me](https://img.shields.io/badge/Sponsor-💖-brightgreen)](https://github.com/sponsors/Cyber-Syntax)
80+
- [![Sponsor Me](https://img.shields.io/badge/Sponsor-💖-brightgreen)](https://github.com/sponsors/Cyber-Syntax)

autotarcompress/__init__.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
"""AutoTarCompress package.
22
33
This package provides a complete backup solution with encryption capabilities.
4-
"""
4+
"""
5+
6+
from importlib.metadata import PackageNotFoundError, version
7+
8+
# Expose managers for direct imports
9+
from autotarcompress.backup_manager import BackupManager
10+
from autotarcompress.cleanup_manager import CleanupManager
11+
from autotarcompress.extract_manager import ExtractManager
12+
from autotarcompress.info_manager import InfoManager
13+
14+
try:
15+
# "autotarcompress" should match the 'name' field in your pyproject.toml
16+
__version__ = version("autotarcompress")
17+
except PackageNotFoundError:
18+
# This happens if the package isn't installed (e.g., running raw scripts)
19+
__version__ = "dev"
20+
21+
22+
__all__ = ["BackupManager", "CleanupManager", "ExtractManager", "InfoManager"]

0 commit comments

Comments
 (0)