Console Documentation

Archive Console

Archive Console is a command-line version of Archive designed for automation, scripting, and power users who prefer terminal-based tools.

Key features:

  • No GUI dependencies - runs on server installations
  • Perfect for scripts and automation
  • Same sync engine as the GUI version
  • Detailed output for logging and monitoring

Installing Console Version

The console version is portable and requires no installation or dependencies.

  1. Download Archive.Console.zip from the releases page
  2. Extract to your preferred location (e.g., C:\Tools\Archive)
  3. Add the folder to your system PATH for easy access

Console Usage

Archive Console uses a command-based interface:

Archive.Console.exe <command> [options]

Available Commands

sync

Synchronize files from source to destination.

Archive.Console.exe sync --source <path> --destination <path> [options]

Options

  • --source, -s : Source directory path (required)
  • --destination, -d : Destination directory path (required)
  • --recursive, -r : Include subdirectories (default: true)
  • --delete-orphaned : Delete files in destination that don't exist in source
  • --verify : Verify files after copying
  • --dry-run : Preview operations without making changes
  • --exclude : Exclude pattern (can be used multiple times)

Console Examples

Basic Sync

Sync documents to external drive:

Archive.Console.exe sync --source "C:\Users\John\Documents" --destination "E:\Backup\Documents"

Dry Run Preview

Preview what would be copied without making changes:

Archive.Console.exe sync --source "C:\Projects" --destination "D:\Backup\Projects" --dry-run

Mirror Sync with Deletion

Create an exact mirror (including deletions):

Archive.Console.exe sync ^
  --source "C:\Photos" ^
  --destination "E:\Backup\Photos" ^
  --delete-orphaned ^
  --verify

With Exclusions

Exclude specific folders and files:

Archive.Console.exe sync ^
  --source "E:\" ^
  --destination "F:\" ^
  --exclude "$RECYCLE.BIN" ^
  --exclude "System Volume Information" ^
  --exclude "*.tmp"

Exit Codes

  • 0 - Success
  • 1 - Error occurred
  • 2 - Cancelled by user

Architecture

Archive is built with a modular architecture:

  • Archive.Core - Core sync engine and business logic
  • Archive.GUI - WPF desktop application
  • Archive.Console - Command-line interface

Both GUI and Console applications use the same Archive.Core library, ensuring consistent behavior.

Technology Stack

  • .NET 9 with C# 12
  • WPF for GUI
  • SQLite for database (GUI only)
  • JSON configuration (Console only)

Database Schema

The GUI version uses SQLite to store configuration and history. The database is located at:

%APPDATA%\Archive\archive.db

Tables

  • Jobs - Backup job configurations
  • JobHistory - Execution history with statistics
  • JobLogs - Detailed file operation logs
  • Settings - Application settings

The database can be accessed directly with SQLite tools for reporting or analysis.

Sync Algorithm

Archive uses a smart synchronization algorithm that:

  1. Compares file modification times and sizes
  2. Identifies files that need to be copied or updated
  3. Detects orphaned files (if deletion is enabled)
  4. Processes files in optimal order
  5. Optionally verifies copied files with hash comparison

File Comparison

A file is considered different if:

  • The destination file doesn't exist
  • File sizes differ
  • Source file modification time is newer than destination

Performance

Archive is optimized for:

  • Fast enumeration of large directory structures
  • Minimal I/O operations
  • Efficient memory usage
  • Cancellable operations

Scripting with Archive Console

Archive Console is perfect for automation scripts. Here's a PowerShell example:

# Backup script with error handling
$source = "C:\Important\Data"
$destination = "E:\Backups\Data"

# Run backup
& "C:\Tools\Archive\Archive.Console.exe" sync `
    --source $source `
    --destination $destination `
    --verify `
    --delete-orphaned

# Check exit code
if ($LASTEXITCODE -eq 0) {
    Write-Host "Backup completed successfully" -ForegroundColor Green
    # Log success
    Add-Content -Path "C:\Logs\backup.log" -Value "$(Get-Date): Success"
} else {
    Write-Host "Backup failed with code $LASTEXITCODE" -ForegroundColor Red
    # Send alert
    Send-MailMessage -To "admin@company.com" -Subject "Backup Failed" -Body "Check logs"
}

Windows Task Scheduler

You can use Windows Task Scheduler to run Archive Console automatically:

  1. Open Task Scheduler
  2. Create a new Basic Task
  3. Set your desired trigger (daily, weekly, etc.)
  4. Action: Start a program
  5. Program: C:\Tools\Archive\Archive.Console.exe
  6. Arguments: sync --source "C:\Data" --destination "E:\Backup"
Tip: Use the GUI version for most scheduling needs - it handles dependencies and has a built-in scheduler. Use Task Scheduler for special requirements like running as a different user.

Contributing

Archive is open source! Contributions are welcome.

  • Report bugs on GitHub Issues
  • Submit pull requests with improvements
  • Suggest features and enhancements