forked from borgbackup/borg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request borgbackup#4696 from jrast/win10
WIP jrast/borg:win10, PR for better review and testing
- Loading branch information
Showing
12 changed files
with
153 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Borg Native on Windows | ||
====================== | ||
|
||
Running borg natively on windows is in a early alpha stage. Expect many things to fail. | ||
Do not use the native windows build on any data which you do not want to lose! | ||
|
||
Build Requirements | ||
------------------ | ||
|
||
- VC 14.0 Compiler | ||
- OpenSSL Library v1.1.1c, 64bit (available at https://slproweb.com/products/Win32OpenSSL.html) | ||
- Patience and a lot of coffee / beer | ||
|
||
What's working | ||
-------------- | ||
|
||
.. note:: | ||
The following examples assume that the `BORG_REPO` and `BORG_PASSPHRASE` environment variables are set | ||
if the repo or passphrase is not explicitly given. | ||
|
||
- Borg does not crash if called with ``borg`` | ||
- ``borg init --encryption repokey-blake2 ./demoRepo`` runs without an error/warning. | ||
Note that absolute paths only work if the protocol is explicitly set to file:// | ||
- ``borg create ::backup-{now} D:\DemoData`` works as expected. | ||
- ``borg list`` works as expected. | ||
- ``borg extract --strip-components 1 ::backup-XXXX`` works. | ||
If absolute paths are extracted, it's important to pass ``--strip-components 1`` as | ||
otherwise the data is resotred to the original location! | ||
|
||
What's NOT working | ||
------------------ | ||
|
||
- Extracting a backup which was created on windows machine on a non windows machine will fail. | ||
- And many things more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
REM Use the downloaded OpenSSL, for all other libraries the bundled version is used. | ||
REM On Appveyor different OpenSSL versions are available, therefore the directory contains the version information. | ||
set BORG_OPENSSL_PREFIX=C:\OpenSSL-v111-Win64 | ||
set BORG_USE_BUNDLED_B2=YES | ||
set BORG_USE_BUNDLED_LZ4=YES | ||
set BORG_USE_BUNDLED_ZSTD=YES | ||
set BORG_USE_BUNDLED_XXHASH=YES | ||
|
||
REM Somehow on my machine rc.exe was not found. Adding the Windows Kit to the path worked. | ||
set PATH=%PATH%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64 | ||
|
||
REM Run the build in the project directory. | ||
SET WORKPATH=%~dp0\.. | ||
pushd %WORKPATH% | ||
|
||
python setup.py clean | ||
pip install -v -e . | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os | ||
import platform | ||
from functools import lru_cache | ||
|
||
|
||
cdef extern from 'windows.h': | ||
ctypedef void* HANDLE | ||
ctypedef int BOOL | ||
ctypedef unsigned long DWORD | ||
|
||
BOOL CloseHandle(HANDLE hObject) | ||
HANDLE OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dbProcessId) | ||
|
||
cdef extern int PROCESS_QUERY_INFORMATION | ||
|
||
|
||
@lru_cache(maxsize=None) | ||
def uid2user(uid, default=None): | ||
return default | ||
|
||
|
||
@lru_cache(maxsize=None) | ||
def user2uid(user, default=None): | ||
return default | ||
|
||
|
||
@lru_cache(maxsize=None) | ||
def gid2group(gid, default=None): | ||
return default | ||
|
||
|
||
@lru_cache(maxsize=None) | ||
def group2gid(group, default=None): | ||
return default | ||
|
||
|
||
def getosusername(): | ||
"""Return the os user name.""" | ||
return os.getlogin() | ||
|
||
|
||
def process_alive(host, pid, thread): | ||
""" | ||
Check if the (host, pid, thread_id) combination corresponds to a potentially alive process. | ||
""" | ||
if host.split('@')[0].lower() != platform.node().lower(): | ||
# Not running on the same node, assume running. | ||
return True | ||
|
||
# If the process can be opened, the process is alive. | ||
handle = OpenProcess(PROCESS_QUERY_INFORMATION, False, pid) | ||
if handle != NULL: | ||
CloseHandle(handle) | ||
return True | ||
return False | ||
|
||
|
||
def local_pid_alive(pid): | ||
"""Return whether *pid* is alive.""" | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters