Skip to content

Commit

Permalink
1.1.6 version
Browse files Browse the repository at this point in the history
  • Loading branch information
lapoigne committed Aug 1, 2018
1 parent 24a5ba3 commit 4664360
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 95 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Borg-installer
CygWin
nsis-2*
http*
ftp*
*.exe
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# borg-cygwin

This creates a standard Windows installer for Borg Backup on 64bit Windows 7 and above.
#### This creates a standard Windows installer for Borg Backup on Windows 7 and above.

* The only prerequisite is NSIS installed, available at http://nsis.sourceforge.net/Download
* The only prerequisite is the presence of NSIS zip, available at [https://sourceforge.net/projects/nsis/files/NSIS%202/2.51/nsis-2.51.zip/download](https://sourceforge.net/projects/nsis/files/NSIS%202/2.51/nsis-2.51.zip/download)
* About 1 GB free disk space required to build installer
* Borg install itself will only require about 150 MB
* Tested on Windows 7 64-bit
* Borg install itself will only require about 165 MB

---

Create the installer by running install.bat. After creating the installer, run it to install Borg.
#### What doesn't work:

Then use borg like this, noting that all file paths are in Cygwin notation e.g. /cygdrive/c/path/to/my/files
* borg mount command : it use FUSE wich is not available on Windows.
* ssh repo like `borg init user@host:repo`; you need to mount the repo as networkdrive first with [WinFsp](http://www.secfs.net/winfsp/) for exemple


---

Create the installer by running build32.bat on 32bit Windows or build64.bat on 64bit Windows. After creating the installer, run it to install Borg.

Then use borg like this, noting that all file paths are in Cygwin notation e.g. /c/path/to/my/files

```
borg init /cygdrive/D/Borg
borg create -C lz4 /cygdrive/D/Borg::Test /cygdrive/C/Photos/
borg init /d/Borg
borg create -C lz4 /d/Borg::Test /c/Photos/
```

The install script first builds borg inside temporary CygWin subfolder, then installs a much smaller release version into the Borg-installer subfolder. Built packages are copied over, unnecessary files removed, and then NSIS is run.

Tested with CygWin 2.4.1, borgbackup 1.0.0 on Windows 7 64-bit.
Tested with CygWin 2.10.0, borgbackup 1.1.6 on Windows 7 32-bit & 64-bit.
17 changes: 0 additions & 17 deletions bin/borg-installer-1.0.7.exe.asc

This file was deleted.

91 changes: 91 additions & 0 deletions build-cygwin.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
@echo off

REM --- Need version at first parameter

if "%~1"=="" GOTO ERROR


REM --- Change to use different CygWin platform and final install path

set CYGSETUP=%1
REM set CYGSETUP=setup-x86.exe
REM set CYGSETUP=setup-x86_64.exe
set TARGETPATH=.

set POWERSHELL=%windir%\System32\WindowsPowerShell\v1.0\powershell.exe

REM --- Fetch Cygwin setup from internet using powershell

"%POWERSHELL%" -Command "(New-Object Net.WebClient).DownloadFile('https://cygwin.com/%CYGSETUP%', '%CYGSETUP%')"

REM --- Install build version of CygWin in a subfolder

set OURPATH=%cd%
set CYGBUILD=%OURPATH%\CygWin
set CYGMIRROR=http://mirrors.kernel.org/sourceware/cygwin/
set BUILDPKGS=python3,python3-devel,python3-setuptools,binutils,gcc-g++,libopenssl,openssl-devel,git,make,openssh,liblz4-devel,liblz4_1,libzstd1,libzstd-devel

%CYGSETUP% -q -B -o -n -g -R %CYGBUILD% -L -D -l %OURPATH% -s %CYGMIRROR% -P %BUILDPKGS%

REM --- Build borgbackup

cd %CYGBUILD%
bin\bash --login -c 'easy_install-3.6 pip'
bin\bash --login -c 'pip install -U borgbackup'
cd %OURPATH%

REM --- Install release version of CygWin in a subfolder

set CYGPATH=%OURPATH%\Borg-installer
del /s /q %CYGPATH%
set INSTALLPKGS=python3,openssh,liblz4_1,python3-setuptools,libzstd1,gcc-g++
set REMOVEPKGS=csih,gawk,lynx,man-db,groff,vim-minimal,tzcode,ncurses,info,util-linux

%CYGSETUP% -q -B -o -n -L -R %CYGPATH% -l %OURPATH% -P %INSTALLPKGS% -x %REMOVEPKGS%

REM --- Adjust final CygWin environment

echo @"%TARGETPATH%\bin\bash" --login -c "cd $(cygpath '%cd%'); /bin/borg %%*" >%CYGPATH%\borg.bat
copy nsswitch.conf %CYGPATH%\etc\
copy fstab %CYGPATH%\etc\

REM --- Copy built packages into release path

cd %CYGBUILD%

copy bin\borg %CYGPATH%\bin
for /d %%d in (lib\python3.6\site-packages\borg*) do xcopy /s /y %%d %CYGPATH%\%%d\
for /d %%d in (lib\python3.6\site-packages\msgpack*) do xcopy /s /y %%d %CYGPATH%\%%d\
for /d %%d in (lib\python3.6\site-packages\pkg_resources) do xcopy /s /y %%d %CYGPATH%\%%d\

REM --- Remove all locales except EN (borg does not use them)

del /s /q %CYGPATH%\usr\share\locale\
for /d %%d in (usr\share\locale\en*) do xcopy /s /y %%d %CYGPATH%\%%d\

REM --- Remove all documentation

del /s /q %CYGPATH%\usr\share\doc\
del /s /q %CYGPATH%\usr\share\info\
del /s /q %CYGPATH%\usr\share\man\

REM --- Remove gcc libs (gcc is installed only for ldconfig support)

del /s /q %CYGPATH%\lib\gcc
del /s /q %CYGPATH%\lib\w32api
del /s /q %CYGPATH%\usr\include\w32api

REM --- Build Installer using NSIS

cd %OURPATH%

build-installer.bat

GOTO END

:ERROR
echo Don't launch this script use build32.bat or build64.bat instead
pause

:END
exit /b
101 changes: 35 additions & 66 deletions build-installer.bat
Original file line number Diff line number Diff line change
@@ -1,70 +1,39 @@
REM --- Change to use different CygWin platform and final install path
@echo off
setlocal

set CYGSETUP=setup-x86_64.exe
set TARGETPATH=.
REM --- NSIS zip must be in folder! Get NSIS from http://nsis.sourceforge.net/Download

REM --- NSIS must be installed! Get NSIS from http://nsis.sourceforge.net/Download

set MAKENSIS=C:\Program Files (x86)\NSIS\makensis.exe
set POWERSHELL=%windir%\System32\WindowsPowerShell\v1.0\powershell.exe

REM --- Fetch Cygwin setup from internet using powershell

"%POWERSHELL%" -Command "(New-Object Net.WebClient).DownloadFile('https://cygwin.com/setup-x86_64.exe', 'setup-x86_64.exe')"

REM --- Install build version of CygWin in a subfolder
REM --- NSIS version
set NSISV=nsis-2.51

set OURPATH=%cd%
set CYGBUILD=%OURPATH%\CygWin
set CYGMIRROR=http://mirrors.kernel.org/sourceware/cygwin/
set BUILDPKGS=python3,python3-devel,python3-setuptools,binutils,gcc-g++,libopenssl,openssl-devel,git,make,openssh,liblz4-devel,liblz4_1

%CYGSETUP% -q -B -o -n -R %CYGBUILD% -L -D -s %CYGMIRROR% -P %BUILDPKGS%

REM --- Build borgbackup

cd %CYGBUILD%
bin\bash --login -c 'easy_install-3.6 pip'
bin\bash --login -c 'pip install borgbackup'
cd %OURPATH%

REM --- Install release version of CygWin in a subfolder

set CYGPATH=%OURPATH%\Borg-installer
set INSTALLPKGS=python3,openssh,liblz4_1,python3-setuptools
set REMOVEPKGS=csih,gawk,lynx,man-db,groff,vim-minimal,tzcode,ncurses,info,util-linux

%CYGSETUP% -q -B -o -n -L -R %CYGPATH% -P %INSTALLPKGS% -x %REMOVEPKGS%

REM --- Adjust final CygWin environment

echo @"%TARGETPATH%\bin\bash" --login -c "cd $(cygpath '%cd%'); /bin/borg %%*" >%CYGPATH%\borg.bat
copy nsswitch.conf %CYGPATH%\etc\
copy fstab %CYGPATH%\etc\

REM --- Copy built packages into release path

cd %CYGBUILD%

copy bin\borg %CYGPATH%\bin
for /d %%d in (lib\python3.6\site-packages\borg*) do xcopy /s %%d %CYGPATH%\%%d\
for /d %%d in (lib\python3.6\site-packages\msgpack*) do xcopy /s %%d %CYGPATH%\%%d\
for /d %%d in (lib\python3.6\site-packages\pkg_resources) do xcopy /s %%d %CYGPATH%\%%d\

REM --- Remove all locales except EN (borg does not use them)

del /s /q %CYGPATH%\usr\share\locale\
for /d %%d in (usr\share\locale\en*) do xcopy /s %%d %CYGPATH%\%%d\

REM --- Remove all documentation

del /s /q %CYGPATH%\usr\share\doc\
del /s /q %CYGPATH%\usr\share\info\
del /s /q %CYGPATH%\usr\share\man\

REM --- Build Installer using NSIS

cd %OURPATH%

"%MAKENSIS%" nsis-installer.nsi

set MAKENSIS="%OURPATH%\%NSISV%\makensis.exe"

IF NOT EXIST "%OURPATH%\%NSISV%.zip" GOTO ERROR

IF NOT EXIST "%OURPATH%\%NSISV%" Call :UnZipFile "%OURPATH%" "%OURPATH%\%NSISV%.zip"

%MAKENSIS% nsis-installer.nsi

exit /b

:UnZipFile <ExtractTo> <newzipfile>
set vbs="%temp%\_.vbs"
if exist %vbs% del /f /q %vbs%
>%vbs% echo Set fso = CreateObject("Scripting.FileSystemObject")
>>%vbs% echo If NOT fso.FolderExists(%1) Then
>>%vbs% echo fso.CreateFolder(%1)
>>%vbs% echo End If
>>%vbs% echo set objShell = CreateObject("Shell.Application")
>>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items
>>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)
>>%vbs% echo Set fso = Nothing
>>%vbs% echo Set objShell = Nothing
cscript //nologo %vbs%
if exist %vbs% del /f /q %vbs%
exit /b

:ERROR
echo Error missing %NSISV%.zip in folder
pause
exit /b
1 change: 1 addition & 0 deletions build32.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build-cygwin.bat setup-x86.exe
1 change: 1 addition & 0 deletions build64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build-cygwin.bat setup-x86_64.exe
3 changes: 2 additions & 1 deletion fstab
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
# see https://cygwin.com/cygwin-ug-net/using.html#mount-table

# BORG INSTALLER: moved drive mount point from /cygdrive to /
none / cygdrive binary,posix=0,user 0 0
none / cygdrive binary,posix=0,user 0 0
none /tmp usertemp binary,posix=0,noacl 0 0
4 changes: 2 additions & 2 deletions nsis-installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; Billy Charlton <[email protected]>
; --------------------------

!define VERSION "1.0.11"
!define VERSION "1.1.6"
!define VERSION_LONG "${VERSION}.0"

!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\BorgBackupUnofficial"
Expand All @@ -24,7 +24,7 @@ Name "Borg Backup ${VERSION}"
OutFile "Borg Backup Installer v${VERSION}.exe"

; The default installation directory
InstallDir "C:\Program Files\Borg"
InstallDir "$PROGRAMFILES64\Borg"

; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
Expand Down

0 comments on commit 4664360

Please sign in to comment.