Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions .github/workflows/build-legacy-restic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
name: Build Legacy Restic (Windows 7 compatible)

# This workflow builds restic with a patched Go compiler that restores Windows 7 support.
# Official Go dropped Windows 7/Server 2008 R2 support in Go 1.21.
# The win7sup patch from DRON-666 re-enables it.

on:
push:
paths:
- '.github/workflows/build-legacy-restic.yml'
- 'RESTIC_SOURCE_FILES/legacy_restic_builder.cmd'
workflow_dispatch:
inputs:
restic_version:
description: 'Restic version to build'
required: true
default: '0.18.1'
go_patch_version:
description: 'Go version to patch (must have win7sup patch available)'
required: true
default: '1.24.2'
architecture:
description: 'Architecture to build'
required: true
default: 'all'
type: choice
options:
- x64
- x86
- all

env:
GO_BOOTSTRAP_VERSION: '1.21.3'
GO23_VERSION: '1.23.8'
# Defaults for push trigger (workflow_dispatch will override via inputs)
DEFAULT_RESTIC_VERSION: '0.18.1'
DEFAULT_GO_PATCH_VERSION: '1.24.2'
DEFAULT_ARCHITECTURE: 'all'

jobs:
build-legacy-restic:
runs-on: windows-2019
env:
RESTIC_VERSION: ${{ inputs.restic_version || '0.18.1' }}
GO_PATCH_VERSION: ${{ inputs.go_patch_version || '1.24.2' }}
ARCHITECTURE: ${{ inputs.architecture || 'all' }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup build environment
shell: pwsh
run: |
$buildDir = "BUILD"
New-Item -ItemType Directory -Force -Path $buildDir
Write-Host "Build directory created: $buildDir"

- name: Download busybox (for tar, patch, wget)
shell: pwsh
run: |
$busyboxUrl = "https://frippery.org/files/busybox/busybox64.exe"
$busyboxPath = "BUILD\busybox64.exe"
Write-Host "Downloading busybox..."
Invoke-WebRequest -Uri $busyboxUrl -OutFile $busyboxPath
Write-Host "Busybox downloaded"

- name: Download Go ${{ env.GO_BOOTSTRAP_VERSION }} (bootstrap, Win7 compatible)
shell: pwsh
run: |
$goUrl = "https://go.dev/dl/go${{ env.GO_BOOTSTRAP_VERSION }}.windows-amd64.zip"
$goZip = "BUILD\go-bootstrap.zip"
Write-Host "Downloading Go ${{ env.GO_BOOTSTRAP_VERSION }} bootstrap..."
Invoke-WebRequest -Uri $goUrl -OutFile $goZip
Expand-Archive -Path $goZip -DestinationPath "BUILD\go-bootstrap-tmp"
Move-Item "BUILD\go-bootstrap-tmp\go" "BUILD\go-bootstrap"
Remove-Item $goZip
Write-Host "Go bootstrap ready"

- name: Download and patch Go ${{ env.GO23_VERSION }}
shell: cmd
run: |
cd BUILD
echo Downloading Go %GO23_VERSION% source...
busybox64.exe wget https://go.dev/dl/go%GO23_VERSION%.src.tar.gz
mkdir go23
busybox64.exe tar x -z --strip-components 1 -C go23 -f go%GO23_VERSION%.src.tar.gz
echo Downloading win7sup patch...
busybox64.exe wget https://gist.github.com/DRON-666/6e29eb6a8635fae9ab822782f34d8fd6/raw/win7sup.diff
cd go23
echo Applying win7sup patch...
..\busybox64.exe patch -p 0 -i ..\win7sup.diff
..\busybox64.exe sed -E -i "s/^go1.+[0-9]$/\0-win7sup/" VERSION
echo Building Go %GO23_VERSION%-win7sup...
cd src
set GOROOT_BOOTSTRAP=%CD%\..\..\go-bootstrap
call make.bat
cd ..\..\..
echo Go %GO23_VERSION%-win7sup built successfully

- name: Download and patch Go ${{ env.GO_PATCH_VERSION }}
shell: cmd
run: |
cd BUILD
echo Downloading Go ${{ env.GO_PATCH_VERSION }} source...
busybox64.exe wget https://go.dev/dl/go${{ env.GO_PATCH_VERSION }}.src.tar.gz
mkdir go-final
busybox64.exe tar x -z --strip-components 1 -C go-final -f go${{ env.GO_PATCH_VERSION }}.src.tar.gz
cd go-final
echo Applying win7sup patch...
..\busybox64.exe patch -p 0 -i ..\win7sup.diff
..\busybox64.exe sed -E -i "s/^go1.+[0-9]$/\0-win7sup/" VERSION
echo Building Go ${{ env.GO_PATCH_VERSION }}-win7sup...
cd src
set GOROOT_BOOTSTRAP=%CD%\..\..\go23
call make.bat
cd ..\..\..
echo Go ${{ env.GO_PATCH_VERSION }}-win7sup built successfully

- name: Download restic ${{ env.RESTIC_VERSION }} source
shell: cmd
run: |
cd BUILD
echo Downloading restic ${{ env.RESTIC_VERSION }}...
busybox64.exe wget https://github.com/restic/restic/releases/download/v${{ env.RESTIC_VERSION }}/restic-${{ env.RESTIC_VERSION }}.tar.gz
mkdir restic-src
busybox64.exe tar x -z --strip-components 1 -C restic-src -f restic-${{ env.RESTIC_VERSION }}.tar.gz
echo Restic source ready

- name: Build restic for amd64
if: ${{ env.ARCHITECTURE == 'x64' || env.ARCHITECTURE == 'all' }}
shell: cmd
run: |
cd BUILD\restic-src
set PATH=%CD%\..\go-final\bin;%PATH%
set GOARCH=amd64
set GOTOOLCHAIN=local
echo Building restic ${{ env.RESTIC_VERSION }} for amd64...
go.exe run build.go
move /y restic.exe ..\restic_${{ env.RESTIC_VERSION }}_windows_legacy_amd64.exe
..\restic_${{ env.RESTIC_VERSION }}_windows_legacy_amd64.exe version
cd ..\..

- name: Build restic for 386
if: ${{ env.ARCHITECTURE == 'x86' || env.ARCHITECTURE == 'all' }}
shell: cmd
run: |
cd BUILD\restic-src
set PATH=%CD%\..\go-final\bin;%PATH%
set GOARCH=386
set GOTOOLCHAIN=local
echo Building restic ${{ env.RESTIC_VERSION }} for 386...
go.exe run build.go
move /y restic.exe ..\restic_${{ env.RESTIC_VERSION }}_windows_legacy_386.exe
..\restic_${{ env.RESTIC_VERSION }}_windows_legacy_386.exe version
cd ..\..

- name: Prepare artifacts
shell: pwsh
run: |
$version = "${{ env.RESTIC_VERSION }}"
$goVersion = "${{ env.GO_PATCH_VERSION }}"
$artifactName = "restic-${version}-win7sup-go${goVersion}"

New-Item -ItemType Directory -Force -Path "artifacts"

Get-ChildItem "BUILD\restic_*_windows_legacy_*.exe" | ForEach-Object {
Copy-Item $_.FullName "artifacts\"
Write-Host "Artifact: $($_.Name)"
# Show version info
& $_.FullName version
}

# Create version info file
@"
Restic version: $version
Go version: $goVersion-win7sup
Build date: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss UTC")
Windows 7/Server 2008 R2 compatible: Yes
"@ | Out-File "artifacts\BUILD-INFO.txt"

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: restic-${{ env.RESTIC_VERSION }}-win7sup-go${{ env.GO_PATCH_VERSION }}
path: artifacts/
retention-days: 90
188 changes: 188 additions & 0 deletions .github/workflows/build-windows7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
name: Build npbackup for Windows 7

on:
push:
branches: [ main, master, win7 ]
tags:
- 'v*'
workflow_dispatch:
inputs:
build_type:
description: 'Build type'
required: true
default: 'gui'
type: choice
options:
- cli
- gui
- viewer
- all
architecture:
description: 'Architecture'
required: true
default: 'x64'
type: choice
options:
- x64
- x86
- both

env:
# Python 3.8 is the last version with Windows 7 support
PYTHON_VERSION: '3.8'

jobs:
build-windows7-x86:
runs-on: windows-2019
if: ${{ github.event.inputs.architecture == 'x86' || github.event.inputs.architecture == 'both' }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python 3.8 (x86)
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x86

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nuitka ordered-set zstandard
pip install -r npbackup/requirements.txt
pip install -r npbackup/requirements-win32.txt
- name: Verify legacy restic binary exists
run: |
if (Test-Path "RESTIC_SOURCE_FILES/restic_*_windows_legacy_386.exe") {
Write-Host "Legacy restic binary for x86 found"
} else {
Write-Error "Legacy restic binary for x86 not found!"
exit 1
}
shell: pwsh

- name: Build GUI (x86)
if: ${{ github.event.inputs.build_type == 'gui' || github.event.inputs.build_type == 'all' || github.event.inputs.build_type == '' }}
run: python bin/compile.py --audience public --build-type gui
env:
PYTHONPATH: .

- name: Build CLI (x86)
if: ${{ github.event.inputs.build_type == 'cli' || github.event.inputs.build_type == 'all' }}
run: python bin/compile.py --audience public --build-type cli
env:
PYTHONPATH: .

- name: Build Viewer (x86)
if: ${{ github.event.inputs.build_type == 'viewer' || github.event.inputs.build_type == 'all' }}
run: python bin/compile.py --audience public --build-type viewer
env:
PYTHONPATH: .

- name: Upload artifacts (x86)
uses: actions/upload-artifact@v4
with:
name: npbackup-windows7-x86-legacy
path: BUILDS/public/windows/x86-legacy/*.zip
if-no-files-found: error

build-windows7-x64:
runs-on: windows-2019
if: ${{ github.event.inputs.architecture == 'x64' || github.event.inputs.architecture == 'both' || github.event.inputs.architecture == '' }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python 3.8 (x64)
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: x64

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nuitka ordered-set zstandard
pip install -r npbackup/requirements.txt
pip install -r npbackup/requirements-win32.txt
- name: Verify legacy restic binary exists
run: |
if (Test-Path "RESTIC_SOURCE_FILES/restic_*_windows_legacy_amd64.exe") {
Write-Host "Legacy restic binary for x64 found"
} else {
Write-Error "Legacy restic binary for x64 not found!"
exit 1
}
shell: pwsh

- name: Build GUI (x64)
if: ${{ github.event.inputs.build_type == 'gui' || github.event.inputs.build_type == 'all' || github.event.inputs.build_type == '' }}
run: |
echo "=== Nuitka version ==="
python -m nuitka --version
echo "=== Running compile.py ==="
python bin/compile.py --audience public --build-type gui 2>&1 | tee build.log
echo "=== Checking for --standalone in command ==="
grep -i "standalone\|onefile" build.log || echo "No standalone/onefile found in log"
env:
PYTHONPATH: .

- name: Build CLI (x64)
if: ${{ github.event.inputs.build_type == 'cli' || github.event.inputs.build_type == 'all' }}
run: python bin/compile.py --audience public --build-type cli
env:
PYTHONPATH: .

- name: Build Viewer (x64)
if: ${{ github.event.inputs.build_type == 'viewer' || github.event.inputs.build_type == 'all' }}
run: python bin/compile.py --audience public --build-type viewer
env:
PYTHONPATH: .

- name: List build output
run: |
echo "=== BUILDS directory structure ==="
Get-ChildItem -Recurse BUILDS -Force | Select-Object FullName, Length
echo "=== Content of .dist folder ==="
Get-ChildItem "BUILDS/public/windows/x64-legacy/npbackup-gui.dist" -Force | Select-Object Name, Length
shell: pwsh

- name: Upload artifacts (x64)
uses: actions/upload-artifact@v4
with:
name: npbackup-windows7-x64-legacy-gui
path: BUILDS/public/windows/x64-legacy/npbackup-gui.dist/
if-no-files-found: error

release:
needs: [build-windows7-x64]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')

steps:
- name: Download x86 artifacts
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: npbackup-windows7-x86-legacy
path: artifacts

- name: Download x64 artifacts
uses: actions/download-artifact@v4
with:
name: npbackup-windows7-x64-legacy
path: artifacts

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/*
draft: true
prerelease: false
fail_on_unmatched_files: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 6 additions & 2 deletions RESTIC_SOURCE_FILES/legacy_restic_builder.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

:: Blatantly copied from https://gist.github.com/DRON-666/6e29eb6a8635fae9ab822782f34d8fd6
:: with some mods to specify restic versions and produce both 32 and 64 bit executables
::
:: This script builds restic with a patched Go compiler that restores Windows 7 support.
:: Official Go dropped Windows 7/Server 2008 R2 support in Go 1.21.
:: The win7sup patch from DRON-666 re-enables it by patching Go source.
:: Without this patch, restic crashes on Windows 7 when using VSS snapshots.

8
SET RESTIC_VERSION=0.18.0
SET RESTIC_VERSION=0.18.1
SET GO_BINARIES_VERSION=1.21.3
SET GO23_VERSION=1.23.8
SET GO24_VERSION=1.24.2
Expand Down
Binary file modified RESTIC_SOURCE_FILES/restic_0.18.1_windows_legacy_386.exe
Binary file not shown.
Binary file modified RESTIC_SOURCE_FILES/restic_0.18.1_windows_legacy_amd64.exe
Binary file not shown.
Loading