Skip to content

auenbauer/backup_amd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated Backup Solution

Automated backup solution for daily backups of:

  • C:\Projects (excluding venv and unnecessary files) → Z:\backup\Projects
  • C:\Users\gleit\Desktop\startZ:\backup\start

Features

  • Incremental Backups: SHA256 checksum-based file comparison for efficient backups
  • Resume Capability: Checkpoint system allows resuming interrupted backups
  • Network Resilience: Retry logic with exponential backoff for network failures
  • Email Notifications: Gmail integration for backup completion and status alerts (optional)
  • Health Monitoring: Backup freshness checks and status reporting
  • Windows Task Scheduler: Automated daily execution
  • Progress Tracking: Real-time progress tracking and detailed logging
  • Pre-flight Checks: Validates system readiness before backup execution

Requirements

  • Python 3.8+
  • Windows 10/11
  • Z: drive mapped and accessible
  • Gmail account (optional, for email notifications)

Installation

1. Clone Repository

git clone https://github.com/auenbauer/backup_amd.git
cd backup_amd

2. Initialize Environment

Run the initialization script:

.\init.ps1

This will:

  • Create a Python virtual environment
  • Install all required dependencies
  • Set up the project structure

3. Manual Setup (Alternative)

# Create virtual environment
py -m venv venv

# Activate virtual environment
.\venv\Scripts\Activate.ps1

# Install dependencies
pip install -r utils/requirements.txt

Configuration

Environment Variables

Create a .env file or set environment variables:

# Source and Destination Paths
SOURCE_PATH_PROJECTS=C:\Projects
SOURCE_PATH_START=C:\Users\gleit\Desktop\start
DESTINATION_PATH=Z:\backup

# Logging
LOG_DIR=logs
CHECKPOINT_FILE=checkpoints/backup_checkpoint.json

# Email Configuration (Optional)
EMAIL_RECIPIENT=your-email@gmail.com
USE_SMTP=false  # Set to true for App Password authentication
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-app-password

Exclusions

By default, the following patterns are excluded:

  • venv/ directories
  • __pycache__/ directories
  • .git/ directories
  • node_modules/ directories
  • .pytest_cache/ directories

Usage

Manual Backup

# Activate virtual environment first
.\venv\Scripts\Activate.ps1

# Run backup
python backup.py backup

Check Backup Status

python backup.py status

Project Structure

backup/
├── state/                  # Project state files
│   ├── plan.md            # Project plan
│   ├── features.json      # Feature tracking
│   └── progress.txt       # Progress log
├── utils/                  # Utilities
│   └── requirements.txt   # Python dependencies
├── test/                   # Test suites
├── src/                    # Source code modules
├── scripts/                # Utility scripts
├── logs/                   # Log files
├── checkpoints/            # Backup checkpoints
├── backup.py              # Main entry point
├── init.ps1               # Initialization script
└── README.md             # This file

Development

Running Tests

# Activate virtual environment
.\venv\Scripts\Activate.ps1

# Run all tests
pytest test/ -v

Testing Email Sending

To test email sending, you need Gmail credentials (App Password):

# Option 1: Command line arguments
py scripts/test_email_sending.py --email your-email@gmail.com --gmail-user your-gmail@gmail.com --app-password your-16-char-password

# Option 2: Environment variables
$env:TEST_EMAIL_TO="your-email@gmail.com"
$env:TEST_GMAIL_USER="your-gmail@gmail.com"
$env:TEST_GMAIL_APP_PASSWORD="your-16-char-password"
py scripts/test_email_sending.py

Getting Gmail App Password:

  1. Go to Google Account settings
  2. Enable 2-Step Verification
  3. Go to App Passwords section
  4. Generate App Password for "Mail"
  5. Use the 16-character password (spaces are OK)

Note: Unit tests mock email sending. The integration test (test/test_email_integration.py) requires credentials and will be skipped without them.

Deployment

Windows Task Scheduler (Recommended)

The system is designed to run on Windows with Task Scheduler:

# Setup scheduled tasks
py scripts/setup_scheduled_tasks.py

# Or generate XML files only
py scripts/setup_scheduled_tasks.py --generate-xml-only

Docker (Not Currently Supported)

Note: This project is designed for Windows-specific deployment:

  • Uses Windows Task Scheduler for automation
  • Accesses Windows network drives (Z: drive)
  • Uses Windows-specific paths and file systems

Docker deployment would require:

  • Linux container with Samba/CIFS for network drive access
  • Cron instead of Task Scheduler
  • Path modifications for Linux filesystem
  • Different credential storage mechanisms

Current Status: Not containerized - designed for native Windows deployment.

Next Steps

  1. Setup Gmail Credentials:

    • Place token.pickle in project root (for OAuth2)
    • Or configure SMTP with App Password
  2. Configure Windows Task Scheduler:

    • Run py scripts/setup_scheduled_tasks.py
    • Backup runs daily at 2:00 AM
    • Status check runs daily at 8:00 AM
  3. Test Email Notifications:

    • Run py scripts/test_gmail_simple.py --email your-email@gmail.com
    • Verify all 4 email types work
  4. Run First Backup:

    • py backup.py --email gleitold@gmail.com
    • Verify backup completes successfully
  5. Monitor:

    • Use py scripts/backup_status_cli.py status for status
    • Check logs in logs/ directory

License

[Specify your license here]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published