PyBackup-Tool


NamePyBackup-Tool JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/ByteStackr/PyBackup-Tool
SummaryZero-dependency Python backup tool with configuration file support
upload_time2025-09-06 03:24:48
maintainerNone
docs_urlNone
authorByteStackr
requires_python>=3.6
licenseMIT
keywords backup cli tool zero-dependency configuration
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyBackup_Tool.py - Complete User Guide

## Overview

PyBackup_Tool.py is a robust, zero-dependency backup solution for codebases with versioning-like features. It creates compressed archives with metadata tracking, supports project-specific configurations, and provides comprehensive backup management capabilities.

## Features

- **Zero Dependencies** - Uses only Python standard library
- **Cross-Platform** - Works on Windows, Linux, macOS
- **Configuration Files** - Project-specific backup settings
- **Dynamic Filenames** - Custom naming with variables
- **Integrity Verification** - SHA256 checksums and validation
- **Flexible Filtering** - Include/exclude patterns
- **Metadata Tracking** - JSON-based backup information
- **AI Summary Support** - External summary integration
- **Cleanup Policies** - Automatic old backup removal

## Quick Start

### 1. Basic Usage (Traditional CLI)

```bash
# Create a backup
python PyBackup_Tool.py backup /path/to/source -d ./backups -n "My Project" -s "Project backup"

# List all backups
python PyBackup_Tool.py list -d ./backups

# Restore a backup
python PyBackup_Tool.py restore backup_20250906_143022_abc123 ./restore -d ./backups
```

### 2. Configuration File Usage (Recommended)

```bash
# Create sample configuration
python PyBackup_Tool.py init-config

# Edit .pybackup.json to customize settings
# Then create backup using config
python PyBackup_Tool.py backup
```

## Installation

No installation required! Simply download `PyBackup_Tool.py` and run with Python 3.6+.

```bash
# Check Python version
python --version

# Make executable (Linux/macOS)
chmod +x PyBackup_Tool.py

# Run directly
python PyBackup_Tool.py --help
```

## Command Reference

### Global Options

```bash
-h, --help     Show help message
-v, --verbose  Enable verbose output
-q, --quiet    Suppress output except errors
```

### Commands

#### `backup` - Create Backup

**Using Configuration File:**
```bash
python PyBackup_Tool.py backup                    # Auto-find config file
python PyBackup_Tool.py backup --config my.json  # Use specific config
```

**Traditional CLI:**
```bash
python PyBackup_Tool.py backup SOURCE_PATH -d DESTINATION [OPTIONS]

Options:
  -d, --destination DIR    Backup destination directory
  -n, --name NAME         Human-readable backup name
  -s, --summary TEXT      Backup summary/description
```

**Examples:**
```bash
# Simple backup
python PyBackup_Tool.py backup ./myproject -d ./backups

# Backup with metadata
python PyBackup_Tool.py backup ./src -d /backup/location -n "Production Build" -s "Pre-deployment backup"

# Using config file
python PyBackup_Tool.py backup
```

#### `list` - List Backups

```bash
python PyBackup_Tool.py list -d BACKUP_LOCATION [OPTIONS]

Options:
  -d, --destination DIR    Backup location
  --format FORMAT         Output format (table, json, simple)
```

**Examples:**
```bash
# Table format (default)
python PyBackup_Tool.py list -d ./backups

# JSON format
python PyBackup_Tool.py list -d ./backups --format json

# Simple format
python PyBackup_Tool.py list -d ./backups --format simple
```

#### `restore` - Restore Backup

```bash
python PyBackup_Tool.py restore BACKUP_ID TARGET_PATH -d BACKUP_LOCATION [OPTIONS]

Options:
  -d, --destination DIR    Backup location (required)
  --no-verify             Skip checksum verification
```

**Examples:**
```bash
# Restore with verification
python PyBackup_Tool.py restore backup_20250906_143022_abc123 ./restored -d ./backups

# Restore without verification
python PyBackup_Tool.py restore backup_20250906_143022_abc123 ./restored -d ./backups --no-verify
```

#### `add-summary` - Add Summary

```bash
python PyBackup_Tool.py add-summary BACKUP_ID "SUMMARY TEXT" -d BACKUP_LOCATION
```

**Examples:**
```bash
# Add AI-generated summary
python PyBackup_Tool.py add-summary backup_20250906_143022_abc123 "Flask web app with user authentication" -d ./backups

# Update existing summary
python PyBackup_Tool.py add-summary backup_20250906_143022_abc123 "Updated: Added payment integration" -d ./backups
```

#### `verify` - Verify Backup

```bash
python PyBackup_Tool.py verify BACKUP_ID -d BACKUP_LOCATION
```

**Examples:**
```bash
# Verify backup integrity
python PyBackup_Tool.py verify backup_20250906_143022_abc123 -d ./backups
```

#### `cleanup` - Clean Old Backups

```bash
python PyBackup_Tool.py cleanup -d BACKUP_LOCATION [OPTIONS]

Options:
  -d, --destination DIR    Backup location (required)
  --max-age DAYS          Maximum age in days
  --keep-count COUNT      Keep last N backups
```

**Examples:**
```bash
# Remove backups older than 30 days
python PyBackup_Tool.py cleanup -d ./backups --max-age 30

# Keep only last 5 backups
python PyBackup_Tool.py cleanup -d ./backups --keep-count 5

# Combine both policies
python PyBackup_Tool.py cleanup -d ./backups --max-age 60 --keep-count 10
```

#### `configure` - Tool Configuration

```bash
python PyBackup_Tool.py configure [OPTIONS]

Options:
  --default-destination DIR    Set default backup destination
  --max-backups COUNT         Set maximum number of backups to keep
```

**Examples:**
```bash
# Show current configuration
python PyBackup_Tool.py configure

# Set default destination
python PyBackup_Tool.py configure --default-destination ./backups

# Set max backups
python PyBackup_Tool.py configure --max-backups 15
```

#### `init-config` - Create Configuration File

```bash
python PyBackup_Tool.py init-config [OPTIONS]

Options:
  --output FILENAME    Output file name (default: .pybackup.json)
```

**Examples:**
```bash
# Create default config file
python PyBackup_Tool.py init-config

# Create custom config file
python PyBackup_Tool.py init-config --output myproject-backup.json
```

## Configuration File Format

### Sample .pybackup.json

```json
{
    "backup_name": "MyProject Backup",
    "source_paths": ["."],
    "destination": "./backups",
    "filename_format": "{DDMMYY}_MyProject_Backup_{SrNo}",
    "archive_format": "tar.gz",
    "include_patterns": [
        "src/**/*",
        "*.py", "*.js", "*.html", "*.css",
        "package.json", "requirements.txt",
        "README.md", "LICENSE"
    ],
    "exclude_patterns": [
        ".git/*",
        "node_modules/*",
        "__pycache__/*",
        "*.pyc", "*.pyo",
        ".env*",
        "*.log", "*.tmp",
        ".vscode/*", ".idea/*",
        "backups/*",
        ".pybackup.json"
    ],
    "compression_level": 6,
    "generate_checksums": true,
    "auto_cleanup": {
        "enabled": true,
        "max_backups": 15,
        "max_age_days": 60
    },
    "summary": {
        "auto_generate": false,
        "default_summary": "Automated backup of {project_name}"
    }
}
```

### Configuration Options

#### Basic Settings
- **`backup_name`** - Human-readable name for backups
- **`source_paths`** - Array of directories to backup (relative to config file)
- **`destination`** - Where to store backup archives
- **`filename_format`** - Custom filename with variables
- **`archive_format`** - Archive type (currently only "tar.gz")
- **`compression_level`** - Gzip compression level (0-9, default: 6)

#### File Filtering
- **`include_patterns`** - Files/patterns to include (supports wildcards)
- **`exclude_patterns`** - Files/patterns to exclude (takes precedence)

#### Advanced Options
- **`generate_checksums`** - Calculate SHA256 checksums (true/false)
- **`auto_cleanup`** - Automatic cleanup policies
- **`summary`** - Default summary settings

### Filename Format Variables

Use these variables in `filename_format`:

#### Date/Time Variables
- **`{DDMMYY}`** - Day/Month/Year (e.g., "060925")
- **`{YYMMDD}`** - Year/Month/Day (e.g., "250906")
- **`{YYYY-MM-DD}`** - Full date (e.g., "2025-09-06")
- **`{HH-MM-SS}`** - Time (e.g., "14-30-22")
- **`{timestamp}`** - Unix timestamp

#### Counter Variables
- **`{SrNo}`** - Sequential number (1, 2, 3...)
- **`{counter}`** - Same as SrNo

#### Project Variables
- **`{project_name}`** - Current directory name
- **`{branch}`** - Git branch name (if available)

**Examples:**
```json
"filename_format": "{DDMMYY}_Backup_{SrNo}"                    // 060925_Backup_1.tar.gz
"filename_format": "{project_name}_{YYYY-MM-DD}_{counter}"     // MyProject_2025-09-06_1.tar.gz
"filename_format": "{branch}_{timestamp}_backup"              // main_1725610800_backup.tar.gz
```

## File Filtering Patterns

### Include Patterns
Specify what files to include in backups:

```json
"include_patterns": [
    "*",                    // Include all files (default)
    "src/**/*",            // All files in src directory and subdirectories
    "*.py",                // All Python files
    "*.{js,ts,jsx,tsx}",   // JavaScript/TypeScript files
    "docs/*.md"            // Markdown files in docs directory
]
```

### Exclude Patterns
Specify what files to exclude (takes precedence over includes):

```json
"exclude_patterns": [
    ".git/*",              // Git directory
    "node_modules/*",      // Node.js dependencies
    "__pycache__/*",       // Python cache
    "*.pyc",               // Compiled Python files
    "*.log",               // Log files
    ".env*",               // Environment files
    "tmp/*",               // Temporary directory
    "backups/*"            // Don't backup the backup directory!
]
```

### Pattern Syntax
- **`*`** - Match any characters except directory separator
- **`**`** - Match any characters including directory separators
- **`?`** - Match single character
- **`[abc]`** - Match any character in brackets
- **`{a,b,c}`** - Match any of the comma-separated patterns

## Workflows

### 1. Personal Project Backup

```bash
# Setup
cd myproject
python PyBackup_Tool.py init-config
# Edit .pybackup.json as needed

# Daily backup
python PyBackup_Tool.py backup

# View backups
python PyBackup_Tool.py list -d ./backups

# Restore if needed
python PyBackup_Tool.py restore backup_id ./recovery -d ./backups
```

### 2. Team Project with Version Control

```bash
# Setup (commit .pybackup.json to git)
python PyBackup_Tool.py init-config
git add .pybackup.json
git commit -m "Add backup configuration"

# Each team member can now:
python PyBackup_Tool.py backup  # Uses same config
```

### 3. Automated Backup Script

```bash
#!/bin/bash
# backup.sh - Automated daily backup

cd /path/to/project
python PyBackup_Tool.py backup

# Add AI summary (example with external tool)
BACKUP_ID=$(python PyBackup_Tool.py list -d ./backups --format json | jq -r '.[0].id')
SUMMARY=$(ai-summarize-tool /path/to/project)
python PyBackup_Tool.py add-summary "$BACKUP_ID" "$SUMMARY" -d ./backups

# Cleanup old backups
python PyBackup_Tool.py cleanup -d ./backups --max-age 30
```

### 4. CI/CD Integration

```yaml
# .github/workflows/backup.yml
name: Backup
on:
  push:
    branches: [main]

jobs:
  backup:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Create backup
      run: |
        python PyBackup_Tool.py backup . -d /backup/storage -n "CI Build ${{ github.run_number }}"
    - name: Cleanup old backups
      run: |
        python PyBackup_Tool.py cleanup -d /backup/storage --keep-count 10
```

## Metadata and Storage

### Backup Metadata Structure

Each backup destination contains a `backups_metadata.json` file:

```json
{
    "backups": [
        {
            "id": "backup_20250906_143022_abc123",
            "timestamp": "2025-09-06T14:30:22Z",
            "source_path": "/path/to/source",
            "archive_name": "backup_20250906_143022_abc123.tar.gz",
            "name": "My Project Backup",
            "file_count": 1247,
            "total_size": 52428800,
            "compressed_size": 12582912,
            "summary": "Flask web application with user authentication",
            "summary_updated": "2025-09-06T14:35:00Z",
            "checksums": {...},
            "include_patterns": ["*"],
            "exclude_patterns": [".git/*", "node_modules/*"]
        }
    ],
    "config": {...},
    "created": "2025-09-06T14:30:22Z",
    "last_modified": "2025-09-06T14:35:00Z",
    "version": "1.0"
}
```

### Directory Structure

```
backup_destination/
├── backups_metadata.json          # Metadata for all backups
├── backup_20250906_143022_abc123.tar.gz    # Backup archive
├── backup_20250906_150500_def456.tar.gz    # Another backup
└── backup_20250906_172000_ghi789.tar.gz    # Latest backup
```

## Advanced Usage

### Custom Configuration File Location

```bash
# Use specific config file
python PyBackup_Tool.py backup --config /path/to/custom.json

# Config file search order:
# 1. --config specified file
# 2. .pybackup.json in current directory
# 3. .pybackup in current directory
# 4. Walk up directory tree looking for config files
# 5. Stop at git root or filesystem root
```

### Multiple Source Paths

```json
{
    "source_paths": [
        "src",
        "docs",
        "config",
        "../shared/common"
    ]
}
```
*Note: Currently only the first source path is used. Multiple paths support is planned for future versions.*

### Integration with External AI Tools

```bash
# Example: Generate summary with external AI tool
BACKUP_ID=$(python PyBackup_Tool.py backup | grep "Backup created" | cut -d: -f2 | tr -d ' ')
SUMMARY=$(curl -X POST "https://api.openai.com/v1/completions" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-3.5-turbo","prompt":"Analyze this codebase and provide a 4-line summary..."}' \
  | jq -r '.choices[0].text')
python PyBackup_Tool.py add-summary "$BACKUP_ID" "$SUMMARY" -d ./backups
```

### Backup Verification Workflow

```bash
# Create backup
BACKUP_ID=$(python PyBackup_Tool.py backup | grep "successfully" | cut -d: -f2 | tr -d ' ')

# Verify immediately
python PyBackup_Tool.py verify "$BACKUP_ID" -d ./backups

# Test restore to temporary location
mkdir temp_restore
python PyBackup_Tool.py restore "$BACKUP_ID" temp_restore -d ./backups
# ... test restored files ...
rm -rf temp_restore
```

## Troubleshooting

### Common Issues

#### 1. Permission Errors
```bash
# Error: Permission denied
# Solution: Check file/directory permissions
ls -la /path/to/backup/destination
chmod 755 /path/to/backup/destination
```

#### 2. Large File Handling
```bash
# Error: Archive too large / Memory error
# Solution: Exclude large files or directories
{
    "exclude_patterns": [
        "*.mp4", "*.avi", "*.mkv",  // Video files
        "*.iso", "*.dmg",           // Disk images
        "data/large_datasets/*",    // Large data directories
        "node_modules/*"            // Dependencies
    ]
}
```

#### 3. Config File Not Found
```bash
# Error: No configuration file found
# Solution: Create config file or specify source path
python PyBackup_Tool.py init-config
# OR
python PyBackup_Tool.py backup /path/to/source -d ./backups
```

#### 4. Checksum Verification Failures
```bash
# Error: Checksum mismatch during restore
# Solution: Re-create backup or restore without verification
python PyBackup_Tool.py restore backup_id ./restore -d ./backups --no-verify
```

#### 5. Windows Path Issues
```bash
# Error: Path issues on Windows
# Solution: Use forward slashes in config files
{
    "destination": "./backups",        // Good
    "source_paths": ["./src"]          // Good
}
```

### Performance Tips

#### 1. Exclude Unnecessary Files
```json
"exclude_patterns": [
    ".git/*",           // Version control
    "node_modules/*",   // Dependencies (can be reinstalled)
    "*.log",           // Log files
    "tmp/*",           // Temporary files
    "__pycache__/*",   // Compiled files
    "*.pyc",
    ".env*",           // Environment files (contain secrets)
    "coverage/*",      // Test coverage reports
    "dist/*",          // Build artifacts
    ".tox/*"           // Testing environments
]
```

#### 2. Optimize Compression
```json
{
    "compression_level": 1    // Faster, larger files
    // OR
    "compression_level": 9    // Slower, smaller files
    // Default: 6 (good balance)
}
```

#### 3. Skip Checksums for Large Backups
```json
{
    "generate_checksums": false    // Faster backup, no verification
}
```

### Debugging

#### Enable Verbose Output
```bash
python PyBackup_Tool.py backup -v    # Verbose mode
python PyBackup_Tool.py list -d ./backups -v
```

#### Check Backup Contents Without Restoring
```bash
# List archive contents (requires manual implementation)
tar -tzf ./backups/backup_20250906_143022_abc123.tar.gz | head -20
```

#### Validate Configuration File
```bash
# Check JSON syntax
python -m json.tool .pybackup.json > /dev/null && echo "Valid JSON" || echo "Invalid JSON"

# Test configuration
python PyBackup_Tool.py backup --config .pybackup.json -v
```

## License

This tool is provided as-is under the MIT License. You're free to modify and distribute it according to your needs.

---

**PyBackup_Tool.py** - Your reliable, zero-dependency backup solution! 🚀

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ByteStackr/PyBackup-Tool",
    "name": "PyBackup-Tool",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "ByteStackr <229177070+ByteStackr@users.noreply.github.com>",
    "keywords": "backup, cli, tool, zero-dependency, configuration",
    "author": "ByteStackr",
    "author_email": "ByteStackr <229177070+ByteStackr@users.noreply.github.com>",
    "download_url": "https://files.pythonhosted.org/packages/06/0f/7ba990a4a35d6ed275ee0deffdd59166e9a7d8f3d623cc72f8b5e227e5d2/pybackup_tool-1.0.0.tar.gz",
    "platform": null,
    "description": "# PyBackup_Tool.py - Complete User Guide\n\n## Overview\n\nPyBackup_Tool.py is a robust, zero-dependency backup solution for codebases with versioning-like features. It creates compressed archives with metadata tracking, supports project-specific configurations, and provides comprehensive backup management capabilities.\n\n## Features\n\n- **Zero Dependencies** - Uses only Python standard library\n- **Cross-Platform** - Works on Windows, Linux, macOS\n- **Configuration Files** - Project-specific backup settings\n- **Dynamic Filenames** - Custom naming with variables\n- **Integrity Verification** - SHA256 checksums and validation\n- **Flexible Filtering** - Include/exclude patterns\n- **Metadata Tracking** - JSON-based backup information\n- **AI Summary Support** - External summary integration\n- **Cleanup Policies** - Automatic old backup removal\n\n## Quick Start\n\n### 1. Basic Usage (Traditional CLI)\n\n```bash\n# Create a backup\npython PyBackup_Tool.py backup /path/to/source -d ./backups -n \"My Project\" -s \"Project backup\"\n\n# List all backups\npython PyBackup_Tool.py list -d ./backups\n\n# Restore a backup\npython PyBackup_Tool.py restore backup_20250906_143022_abc123 ./restore -d ./backups\n```\n\n### 2. Configuration File Usage (Recommended)\n\n```bash\n# Create sample configuration\npython PyBackup_Tool.py init-config\n\n# Edit .pybackup.json to customize settings\n# Then create backup using config\npython PyBackup_Tool.py backup\n```\n\n## Installation\n\nNo installation required! Simply download `PyBackup_Tool.py` and run with Python 3.6+.\n\n```bash\n# Check Python version\npython --version\n\n# Make executable (Linux/macOS)\nchmod +x PyBackup_Tool.py\n\n# Run directly\npython PyBackup_Tool.py --help\n```\n\n## Command Reference\n\n### Global Options\n\n```bash\n-h, --help     Show help message\n-v, --verbose  Enable verbose output\n-q, --quiet    Suppress output except errors\n```\n\n### Commands\n\n#### `backup` - Create Backup\n\n**Using Configuration File:**\n```bash\npython PyBackup_Tool.py backup                    # Auto-find config file\npython PyBackup_Tool.py backup --config my.json  # Use specific config\n```\n\n**Traditional CLI:**\n```bash\npython PyBackup_Tool.py backup SOURCE_PATH -d DESTINATION [OPTIONS]\n\nOptions:\n  -d, --destination DIR    Backup destination directory\n  -n, --name NAME         Human-readable backup name\n  -s, --summary TEXT      Backup summary/description\n```\n\n**Examples:**\n```bash\n# Simple backup\npython PyBackup_Tool.py backup ./myproject -d ./backups\n\n# Backup with metadata\npython PyBackup_Tool.py backup ./src -d /backup/location -n \"Production Build\" -s \"Pre-deployment backup\"\n\n# Using config file\npython PyBackup_Tool.py backup\n```\n\n#### `list` - List Backups\n\n```bash\npython PyBackup_Tool.py list -d BACKUP_LOCATION [OPTIONS]\n\nOptions:\n  -d, --destination DIR    Backup location\n  --format FORMAT         Output format (table, json, simple)\n```\n\n**Examples:**\n```bash\n# Table format (default)\npython PyBackup_Tool.py list -d ./backups\n\n# JSON format\npython PyBackup_Tool.py list -d ./backups --format json\n\n# Simple format\npython PyBackup_Tool.py list -d ./backups --format simple\n```\n\n#### `restore` - Restore Backup\n\n```bash\npython PyBackup_Tool.py restore BACKUP_ID TARGET_PATH -d BACKUP_LOCATION [OPTIONS]\n\nOptions:\n  -d, --destination DIR    Backup location (required)\n  --no-verify             Skip checksum verification\n```\n\n**Examples:**\n```bash\n# Restore with verification\npython PyBackup_Tool.py restore backup_20250906_143022_abc123 ./restored -d ./backups\n\n# Restore without verification\npython PyBackup_Tool.py restore backup_20250906_143022_abc123 ./restored -d ./backups --no-verify\n```\n\n#### `add-summary` - Add Summary\n\n```bash\npython PyBackup_Tool.py add-summary BACKUP_ID \"SUMMARY TEXT\" -d BACKUP_LOCATION\n```\n\n**Examples:**\n```bash\n# Add AI-generated summary\npython PyBackup_Tool.py add-summary backup_20250906_143022_abc123 \"Flask web app with user authentication\" -d ./backups\n\n# Update existing summary\npython PyBackup_Tool.py add-summary backup_20250906_143022_abc123 \"Updated: Added payment integration\" -d ./backups\n```\n\n#### `verify` - Verify Backup\n\n```bash\npython PyBackup_Tool.py verify BACKUP_ID -d BACKUP_LOCATION\n```\n\n**Examples:**\n```bash\n# Verify backup integrity\npython PyBackup_Tool.py verify backup_20250906_143022_abc123 -d ./backups\n```\n\n#### `cleanup` - Clean Old Backups\n\n```bash\npython PyBackup_Tool.py cleanup -d BACKUP_LOCATION [OPTIONS]\n\nOptions:\n  -d, --destination DIR    Backup location (required)\n  --max-age DAYS          Maximum age in days\n  --keep-count COUNT      Keep last N backups\n```\n\n**Examples:**\n```bash\n# Remove backups older than 30 days\npython PyBackup_Tool.py cleanup -d ./backups --max-age 30\n\n# Keep only last 5 backups\npython PyBackup_Tool.py cleanup -d ./backups --keep-count 5\n\n# Combine both policies\npython PyBackup_Tool.py cleanup -d ./backups --max-age 60 --keep-count 10\n```\n\n#### `configure` - Tool Configuration\n\n```bash\npython PyBackup_Tool.py configure [OPTIONS]\n\nOptions:\n  --default-destination DIR    Set default backup destination\n  --max-backups COUNT         Set maximum number of backups to keep\n```\n\n**Examples:**\n```bash\n# Show current configuration\npython PyBackup_Tool.py configure\n\n# Set default destination\npython PyBackup_Tool.py configure --default-destination ./backups\n\n# Set max backups\npython PyBackup_Tool.py configure --max-backups 15\n```\n\n#### `init-config` - Create Configuration File\n\n```bash\npython PyBackup_Tool.py init-config [OPTIONS]\n\nOptions:\n  --output FILENAME    Output file name (default: .pybackup.json)\n```\n\n**Examples:**\n```bash\n# Create default config file\npython PyBackup_Tool.py init-config\n\n# Create custom config file\npython PyBackup_Tool.py init-config --output myproject-backup.json\n```\n\n## Configuration File Format\n\n### Sample .pybackup.json\n\n```json\n{\n    \"backup_name\": \"MyProject Backup\",\n    \"source_paths\": [\".\"],\n    \"destination\": \"./backups\",\n    \"filename_format\": \"{DDMMYY}_MyProject_Backup_{SrNo}\",\n    \"archive_format\": \"tar.gz\",\n    \"include_patterns\": [\n        \"src/**/*\",\n        \"*.py\", \"*.js\", \"*.html\", \"*.css\",\n        \"package.json\", \"requirements.txt\",\n        \"README.md\", \"LICENSE\"\n    ],\n    \"exclude_patterns\": [\n        \".git/*\",\n        \"node_modules/*\",\n        \"__pycache__/*\",\n        \"*.pyc\", \"*.pyo\",\n        \".env*\",\n        \"*.log\", \"*.tmp\",\n        \".vscode/*\", \".idea/*\",\n        \"backups/*\",\n        \".pybackup.json\"\n    ],\n    \"compression_level\": 6,\n    \"generate_checksums\": true,\n    \"auto_cleanup\": {\n        \"enabled\": true,\n        \"max_backups\": 15,\n        \"max_age_days\": 60\n    },\n    \"summary\": {\n        \"auto_generate\": false,\n        \"default_summary\": \"Automated backup of {project_name}\"\n    }\n}\n```\n\n### Configuration Options\n\n#### Basic Settings\n- **`backup_name`** - Human-readable name for backups\n- **`source_paths`** - Array of directories to backup (relative to config file)\n- **`destination`** - Where to store backup archives\n- **`filename_format`** - Custom filename with variables\n- **`archive_format`** - Archive type (currently only \"tar.gz\")\n- **`compression_level`** - Gzip compression level (0-9, default: 6)\n\n#### File Filtering\n- **`include_patterns`** - Files/patterns to include (supports wildcards)\n- **`exclude_patterns`** - Files/patterns to exclude (takes precedence)\n\n#### Advanced Options\n- **`generate_checksums`** - Calculate SHA256 checksums (true/false)\n- **`auto_cleanup`** - Automatic cleanup policies\n- **`summary`** - Default summary settings\n\n### Filename Format Variables\n\nUse these variables in `filename_format`:\n\n#### Date/Time Variables\n- **`{DDMMYY}`** - Day/Month/Year (e.g., \"060925\")\n- **`{YYMMDD}`** - Year/Month/Day (e.g., \"250906\")\n- **`{YYYY-MM-DD}`** - Full date (e.g., \"2025-09-06\")\n- **`{HH-MM-SS}`** - Time (e.g., \"14-30-22\")\n- **`{timestamp}`** - Unix timestamp\n\n#### Counter Variables\n- **`{SrNo}`** - Sequential number (1, 2, 3...)\n- **`{counter}`** - Same as SrNo\n\n#### Project Variables\n- **`{project_name}`** - Current directory name\n- **`{branch}`** - Git branch name (if available)\n\n**Examples:**\n```json\n\"filename_format\": \"{DDMMYY}_Backup_{SrNo}\"                    // 060925_Backup_1.tar.gz\n\"filename_format\": \"{project_name}_{YYYY-MM-DD}_{counter}\"     // MyProject_2025-09-06_1.tar.gz\n\"filename_format\": \"{branch}_{timestamp}_backup\"              // main_1725610800_backup.tar.gz\n```\n\n## File Filtering Patterns\n\n### Include Patterns\nSpecify what files to include in backups:\n\n```json\n\"include_patterns\": [\n    \"*\",                    // Include all files (default)\n    \"src/**/*\",            // All files in src directory and subdirectories\n    \"*.py\",                // All Python files\n    \"*.{js,ts,jsx,tsx}\",   // JavaScript/TypeScript files\n    \"docs/*.md\"            // Markdown files in docs directory\n]\n```\n\n### Exclude Patterns\nSpecify what files to exclude (takes precedence over includes):\n\n```json\n\"exclude_patterns\": [\n    \".git/*\",              // Git directory\n    \"node_modules/*\",      // Node.js dependencies\n    \"__pycache__/*\",       // Python cache\n    \"*.pyc\",               // Compiled Python files\n    \"*.log\",               // Log files\n    \".env*\",               // Environment files\n    \"tmp/*\",               // Temporary directory\n    \"backups/*\"            // Don't backup the backup directory!\n]\n```\n\n### Pattern Syntax\n- **`*`** - Match any characters except directory separator\n- **`**`** - Match any characters including directory separators\n- **`?`** - Match single character\n- **`[abc]`** - Match any character in brackets\n- **`{a,b,c}`** - Match any of the comma-separated patterns\n\n## Workflows\n\n### 1. Personal Project Backup\n\n```bash\n# Setup\ncd myproject\npython PyBackup_Tool.py init-config\n# Edit .pybackup.json as needed\n\n# Daily backup\npython PyBackup_Tool.py backup\n\n# View backups\npython PyBackup_Tool.py list -d ./backups\n\n# Restore if needed\npython PyBackup_Tool.py restore backup_id ./recovery -d ./backups\n```\n\n### 2. Team Project with Version Control\n\n```bash\n# Setup (commit .pybackup.json to git)\npython PyBackup_Tool.py init-config\ngit add .pybackup.json\ngit commit -m \"Add backup configuration\"\n\n# Each team member can now:\npython PyBackup_Tool.py backup  # Uses same config\n```\n\n### 3. Automated Backup Script\n\n```bash\n#!/bin/bash\n# backup.sh - Automated daily backup\n\ncd /path/to/project\npython PyBackup_Tool.py backup\n\n# Add AI summary (example with external tool)\nBACKUP_ID=$(python PyBackup_Tool.py list -d ./backups --format json | jq -r '.[0].id')\nSUMMARY=$(ai-summarize-tool /path/to/project)\npython PyBackup_Tool.py add-summary \"$BACKUP_ID\" \"$SUMMARY\" -d ./backups\n\n# Cleanup old backups\npython PyBackup_Tool.py cleanup -d ./backups --max-age 30\n```\n\n### 4. CI/CD Integration\n\n```yaml\n# .github/workflows/backup.yml\nname: Backup\non:\n  push:\n    branches: [main]\n\njobs:\n  backup:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v2\n    - name: Create backup\n      run: |\n        python PyBackup_Tool.py backup . -d /backup/storage -n \"CI Build ${{ github.run_number }}\"\n    - name: Cleanup old backups\n      run: |\n        python PyBackup_Tool.py cleanup -d /backup/storage --keep-count 10\n```\n\n## Metadata and Storage\n\n### Backup Metadata Structure\n\nEach backup destination contains a `backups_metadata.json` file:\n\n```json\n{\n    \"backups\": [\n        {\n            \"id\": \"backup_20250906_143022_abc123\",\n            \"timestamp\": \"2025-09-06T14:30:22Z\",\n            \"source_path\": \"/path/to/source\",\n            \"archive_name\": \"backup_20250906_143022_abc123.tar.gz\",\n            \"name\": \"My Project Backup\",\n            \"file_count\": 1247,\n            \"total_size\": 52428800,\n            \"compressed_size\": 12582912,\n            \"summary\": \"Flask web application with user authentication\",\n            \"summary_updated\": \"2025-09-06T14:35:00Z\",\n            \"checksums\": {...},\n            \"include_patterns\": [\"*\"],\n            \"exclude_patterns\": [\".git/*\", \"node_modules/*\"]\n        }\n    ],\n    \"config\": {...},\n    \"created\": \"2025-09-06T14:30:22Z\",\n    \"last_modified\": \"2025-09-06T14:35:00Z\",\n    \"version\": \"1.0\"\n}\n```\n\n### Directory Structure\n\n```\nbackup_destination/\n\u251c\u2500\u2500 backups_metadata.json          # Metadata for all backups\n\u251c\u2500\u2500 backup_20250906_143022_abc123.tar.gz    # Backup archive\n\u251c\u2500\u2500 backup_20250906_150500_def456.tar.gz    # Another backup\n\u2514\u2500\u2500 backup_20250906_172000_ghi789.tar.gz    # Latest backup\n```\n\n## Advanced Usage\n\n### Custom Configuration File Location\n\n```bash\n# Use specific config file\npython PyBackup_Tool.py backup --config /path/to/custom.json\n\n# Config file search order:\n# 1. --config specified file\n# 2. .pybackup.json in current directory\n# 3. .pybackup in current directory\n# 4. Walk up directory tree looking for config files\n# 5. Stop at git root or filesystem root\n```\n\n### Multiple Source Paths\n\n```json\n{\n    \"source_paths\": [\n        \"src\",\n        \"docs\",\n        \"config\",\n        \"../shared/common\"\n    ]\n}\n```\n*Note: Currently only the first source path is used. Multiple paths support is planned for future versions.*\n\n### Integration with External AI Tools\n\n```bash\n# Example: Generate summary with external AI tool\nBACKUP_ID=$(python PyBackup_Tool.py backup | grep \"Backup created\" | cut -d: -f2 | tr -d ' ')\nSUMMARY=$(curl -X POST \"https://api.openai.com/v1/completions\" \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"gpt-3.5-turbo\",\"prompt\":\"Analyze this codebase and provide a 4-line summary...\"}' \\\n  | jq -r '.choices[0].text')\npython PyBackup_Tool.py add-summary \"$BACKUP_ID\" \"$SUMMARY\" -d ./backups\n```\n\n### Backup Verification Workflow\n\n```bash\n# Create backup\nBACKUP_ID=$(python PyBackup_Tool.py backup | grep \"successfully\" | cut -d: -f2 | tr -d ' ')\n\n# Verify immediately\npython PyBackup_Tool.py verify \"$BACKUP_ID\" -d ./backups\n\n# Test restore to temporary location\nmkdir temp_restore\npython PyBackup_Tool.py restore \"$BACKUP_ID\" temp_restore -d ./backups\n# ... test restored files ...\nrm -rf temp_restore\n```\n\n## Troubleshooting\n\n### Common Issues\n\n#### 1. Permission Errors\n```bash\n# Error: Permission denied\n# Solution: Check file/directory permissions\nls -la /path/to/backup/destination\nchmod 755 /path/to/backup/destination\n```\n\n#### 2. Large File Handling\n```bash\n# Error: Archive too large / Memory error\n# Solution: Exclude large files or directories\n{\n    \"exclude_patterns\": [\n        \"*.mp4\", \"*.avi\", \"*.mkv\",  // Video files\n        \"*.iso\", \"*.dmg\",           // Disk images\n        \"data/large_datasets/*\",    // Large data directories\n        \"node_modules/*\"            // Dependencies\n    ]\n}\n```\n\n#### 3. Config File Not Found\n```bash\n# Error: No configuration file found\n# Solution: Create config file or specify source path\npython PyBackup_Tool.py init-config\n# OR\npython PyBackup_Tool.py backup /path/to/source -d ./backups\n```\n\n#### 4. Checksum Verification Failures\n```bash\n# Error: Checksum mismatch during restore\n# Solution: Re-create backup or restore without verification\npython PyBackup_Tool.py restore backup_id ./restore -d ./backups --no-verify\n```\n\n#### 5. Windows Path Issues\n```bash\n# Error: Path issues on Windows\n# Solution: Use forward slashes in config files\n{\n    \"destination\": \"./backups\",        // Good\n    \"source_paths\": [\"./src\"]          // Good\n}\n```\n\n### Performance Tips\n\n#### 1. Exclude Unnecessary Files\n```json\n\"exclude_patterns\": [\n    \".git/*\",           // Version control\n    \"node_modules/*\",   // Dependencies (can be reinstalled)\n    \"*.log\",           // Log files\n    \"tmp/*\",           // Temporary files\n    \"__pycache__/*\",   // Compiled files\n    \"*.pyc\",\n    \".env*\",           // Environment files (contain secrets)\n    \"coverage/*\",      // Test coverage reports\n    \"dist/*\",          // Build artifacts\n    \".tox/*\"           // Testing environments\n]\n```\n\n#### 2. Optimize Compression\n```json\n{\n    \"compression_level\": 1    // Faster, larger files\n    // OR\n    \"compression_level\": 9    // Slower, smaller files\n    // Default: 6 (good balance)\n}\n```\n\n#### 3. Skip Checksums for Large Backups\n```json\n{\n    \"generate_checksums\": false    // Faster backup, no verification\n}\n```\n\n### Debugging\n\n#### Enable Verbose Output\n```bash\npython PyBackup_Tool.py backup -v    # Verbose mode\npython PyBackup_Tool.py list -d ./backups -v\n```\n\n#### Check Backup Contents Without Restoring\n```bash\n# List archive contents (requires manual implementation)\ntar -tzf ./backups/backup_20250906_143022_abc123.tar.gz | head -20\n```\n\n#### Validate Configuration File\n```bash\n# Check JSON syntax\npython -m json.tool .pybackup.json > /dev/null && echo \"Valid JSON\" || echo \"Invalid JSON\"\n\n# Test configuration\npython PyBackup_Tool.py backup --config .pybackup.json -v\n```\n\n## License\n\nThis tool is provided as-is under the MIT License. You're free to modify and distribute it according to your needs.\n\n---\n\n**PyBackup_Tool.py** - Your reliable, zero-dependency backup solution! \ud83d\ude80\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Zero-dependency Python backup tool with configuration file support",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/ByteStackr/PyBackup-Tool/issues",
        "Documentation": "https://github.com/ByteStackr/PyBackup-Tool#readme",
        "Homepage": "https://github.com/ByteStackr/PyBackup-Tool",
        "Repository": "https://github.com/ByteStackr/PyBackup-Tool.git"
    },
    "split_keywords": [
        "backup",
        " cli",
        " tool",
        " zero-dependency",
        " configuration"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "80e97356d0348f75e978456a3a3347bc8b6555a22ece3149cdcf41563c29ff0a",
                "md5": "6278a755185158936dda3f1fb3aac411",
                "sha256": "b03d1d16650ecdd3c6d4f5b8da6f7e8ebde5dfe3511172a2679bc0e962fd5c2a"
            },
            "downloads": -1,
            "filename": "pybackup_tool-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6278a755185158936dda3f1fb3aac411",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 20823,
            "upload_time": "2025-09-06T03:24:47",
            "upload_time_iso_8601": "2025-09-06T03:24:47.274638Z",
            "url": "https://files.pythonhosted.org/packages/80/e9/7356d0348f75e978456a3a3347bc8b6555a22ece3149cdcf41563c29ff0a/pybackup_tool-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "060f7ba990a4a35d6ed275ee0deffdd59166e9a7d8f3d623cc72f8b5e227e5d2",
                "md5": "ef9d167089aa2b40d9d427f0e879408a",
                "sha256": "780f0862346b0caa22c2bf3e55ad82b6c67bc50182fd2700b8c541543a59b304"
            },
            "downloads": -1,
            "filename": "pybackup_tool-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ef9d167089aa2b40d9d427f0e879408a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 28426,
            "upload_time": "2025-09-06T03:24:48",
            "upload_time_iso_8601": "2025-09-06T03:24:48.356466Z",
            "url": "https://files.pythonhosted.org/packages/06/0f/7ba990a4a35d6ed275ee0deffdd59166e9a7d8f3d623cc72f8b5e227e5d2/pybackup_tool-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-06 03:24:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ByteStackr",
    "github_project": "PyBackup-Tool",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pybackup-tool"
}
        
Elapsed time: 3.44333s