Skip to content

Reports and Job Exports

Andrew Paolucci edited this page Nov 19, 2026 · 1 revision

Reports, .rcj Job Files & Script Exports

robocopy2rust provides full interoperability with legacy Windows administration artifacts—producing air-gapped audit bundles, bidirectional Microsoft .rcj files, .bat/.ps1 scripts, and schtasks registrations.


1. Air-Gapped Audit Reports (robocopy2rust-report)

Supported formats (ReportFormat): html, json, markdown, or all (writes .html, .json, and .md together; defaults to stem robocopy2rust_report if a directory path is supplied).

Single-File HTML Report (report/src/html.rs)

  • Zero External Assets: 100% inline CSS and vanilla JavaScript — zero CDNs, zero Google Fonts, zero <script src=...>, zero network calls on open (safe inside air-gapped OT/server networks).
  • Dashboard Cards: Status badge (SUCCESS / FAILED / CANCELLED), mode badge (DRY-RUN (/L) vs LIVE EXECUTION), Exit Code, Files Copied/Total, Bytes Copied, Failed/Extras, and Throughput.
  • Interactive Controls: Built-in Toggle Theme (light ↔ body.dark) and live text filter (filterRows()) across the File & Directory Actions table.
  • XSS-Escaped Output: Every rendered path, job title, error, and log digest is HTML-escaped.
  • Integrity Footer: Displays the raw log's SHA-256 hash (log_sha256).

JSON (report/src/json.rs) & Markdown (report/src/markdown.rs)

  • JSON Envelope (robocopy2rust.audit.v1): Wraps schema, generated_at (RFC 3339), and the complete RunResult payload (args, summary, exit_info, file_actions, errors, log_lines, log_sha256).
  • Markdown Audit: Clean GitHub-Flavored Markdown table summaries (Dirs, Files, Bytes matrix, exit-code bit descriptions, command block, errors list, and parsed file action table) suitable for tickets or PR logs.

Legacy Robocopy Log Importer (parse_log_file_to_run_result)

Converts existing Windows Robocopy .log or /UNILOG files into full HTML/JSON/Markdown audit bundles without re-running Robocopy:

  • Decodes UTF-8, UTF-8 with BOM, UTF-16LE (FF FE), and UTF-16BE (FE FF).
  • Extracts Source :, Dest :, Options : (detecting /L dry-run mode), timestamps, all 15 FileActionKind action classes, ERROR <n> lines, and summary counters.
  • Computes the equivalent bitmask exit code (0x01 copied, 0x02 extras, 0x04 mismatch, 0x08 failed/errors) and SHA-256 log digest.

2. Bidirectional .rcj Robocopy Job Files (core/src/rcj.rs)

Microsoft Robocopy uses .rcj files with /SAVE:<name> and /JOB:<name>, often saved by Windows in UTF-16LE with BOM.

  • parse_rcj(bytes):
    • Automatically decodes UTF-16LE (FF FE), UTF-16BE (FE FF), UTF-8 BOM (EF BB BF), or plain UTF-8.
    • Parses /SD: (Source Directory) and /DD: (Destination Directory) using unquoted values.
    • Tracks multiline /IF (Include Files), /XF (Exclude Files), and /XD (Exclude Directories) blocks cleanly.
    • Strips :: comment annotations only outside double quotes (clean_rcj_line), so UNC paths or spaces remain intact.
  • serialize_rcj(job):
    • Outputs standard Microsoft-compatible .rcj files with \r\n CRLF endings, header comments, /SD://NOSD, /DD://NODD, /IF, sorted scalar switches, /XF, and normalized /XD sections.

3. Standalone Wrapper Scripts & Task Scheduler (core/src/command.rs)

Batch Script (.bat — build_batch_script)

Generates an @echo off + setlocal script with proper Robocopy bitmask exit handling (0..=7 → exit /b 0; GEQ 8 → fails with %RC%):

@echo off
setlocal
rem Generated by robocopy2rust - Safe Incremental Backup
echo Starting Robocopy job: Safe Incremental Backup
robocopy "C:\Data Src" D:\Backup /E /MT:8 /XJ /R:3 /W:5 /ETA
set "RC=%ERRORLEVEL%"
echo Robocopy exited with bitmask code %RC%
if %RC% GEQ 8 (
    echo [ERROR] Robocopy encountered copy or fatal errors ^(code %RC%^).
    exit /b %RC%
)
exit /b 0

PowerShell Script (.ps1 — build_powershell_script)

Avoids fragile string concatenation by emitting an explicit @(...) splatted argument array with single-quote escaping (''):

# Generated by robocopy2rust - Safe Incremental Backup
$ErrorActionPreference = 'Stop'
$robocopyArgs = @(
    'C:\Data Src',
    'D:\Backup',
    '/E',
    '/MT:8',
    '/XJ',
    '/R:3',
    '/W:5',
    '/ETA'
)
Write-Host 'Starting Robocopy job: Safe Incremental Backup'
& robocopy.exe @robocopyArgs
$rc = $LASTEXITCODE
Write-Host "Robocopy exited with bitmask code $rc"
if ($rc -ge 8) {
    Write-Error "Robocopy failed with exit code $rc"
    exit $rc
}
exit 0

Windows Task Scheduler (build_schtasks_command)

Generates properly quoted schtasks /Create commands supporting cadences:

  • DAILY (/ST HH:MM)
  • WEEKLY (/D <days> + /ST HH:MM)
  • HOURLY (/ST HH:MM)
  • ONSTART
  • ONLOGON

Appends /RL HIGHEST (when elevated execution is selected) and /F (force overwrite existing task definition).

Clone this wiki locally