├── .github └── workflows │ ├── macosx.yaml │ ├── main.yaml │ └── pypi.yaml ├── .gitignore ├── LICENSE ├── README.rst ├── media └── backfriend-client-screenshot.png ├── requirements.txt ├── setup.py └── src ├── backupfriend-client.py ├── backupfriend-client.spec ├── backupfriend ├── __init__.py ├── common.py ├── config │ ├── config-osx.yml │ ├── config-windows.yml │ └── config.yml ├── images │ ├── icon.icns │ └── icon.png ├── main.py ├── make_ssh_key.py ├── res │ ├── main.fbp │ └── main.xrc └── sub.py ├── backupfriendclient.py ├── build-scripts └── get_ssh_bin └── build.txt /.github/workflows/macosx.yaml: -------------------------------------------------------------------------------- 1 | name: Package Application for Mac OS X 2 | on: [push, pull_request] 3 | 4 | 5 | jobs: 6 | build: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | matrix: 10 | # os: [ubuntu-latest, macos-latest, windows-latest] 11 | os: [macos-latest] 12 | steps: 13 | - uses: actions/checkout@master 14 | - name: Install rdiff-backup 15 | run: | 16 | brew update 17 | brew install python@3.9 18 | brew install rdiff-backup 19 | brew install wxpython 20 | brew install libyaml 21 | brew upgrade 22 | - name: Display Brew path 23 | run: brew --prefix 24 | - name: which python3 25 | run: which python3 26 | - name: Display Python version 27 | run: python3 -c "import sys; print(sys.version)" 28 | - name: Install py2app 29 | run: python3 -m pip install py2app 30 | - name: upgrade pip 31 | run: python3 -m pip install --upgrade pip 32 | - name: install rdiff-backup via pip 33 | run: python3 -m pip install rdiff-backup 34 | - name: install requirements.txt 35 | run: python3 -m pip install -r requirements.txt 36 | - name: Build app 37 | run: python3 setup.py py2app 38 | - name: Codesign executable 39 | env: 40 | MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} 41 | MACOS_CERTIFICATE_ID: ${{ secrets.MACOS_CERTIFICATE_ID }} 42 | MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }} 43 | run: | 44 | echo ${MACOS_CERTIFICATE} | base64 --decode > certificate.p12 45 | echo A 46 | security create-keychain -p build.keychain build.keychain1 47 | echo B 48 | security default-keychain -s build.keychain1 49 | echo C 50 | security unlock-keychain -p build.keychain build.keychain1 51 | echo D 52 | security import certificate.p12 -k build.keychain1 -P ${MACOS_CERTIFICATE_PWD} -T /usr/bin/codesign 53 | echo E 54 | security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k build.keychain build.keychain1 55 | echo F 56 | echo G 57 | /usr/bin/codesign --force --deep -s "Developer ID Application: Guy Sheffer (K8784SVNX8)" dist/BackupFriend.app -v 58 | echo H 59 | /usr/bin/codesign --force --deep -s "Developer ID Application: Guy Sheffer (K8784SVNX8)" dist/BackupFriend.app/Contents/Frameworks/Python.framework/Versions/Current -v 60 | /usr/bin/codesign --force --deep -s "Developer ID Application: Guy Sheffer (K8784SVNX8)" dist/BackupFriend.app/Contents/Frameworks/Python.framework -v 61 | /usr/bin/codesign --verify --verbose dist/BackupFriend.app 62 | tar czvf dist/BackupFriend.tar.gz -C dist BackupFriend.app 63 | rm -rf dist/BackupFriend.app 64 | rm -fr *.p12 65 | - uses: actions/upload-artifact@v2 66 | with: 67 | name: backupfriend-client-macos 68 | path: dist/ 69 | -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: Package Application with Pyinstaller 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | 13 | - name: wget-rdiff-backup 14 | uses: wei/wget@v1 15 | with: 16 | args: -O rdiff-backup-2.0.5.win32exe.zip https://github.com/rdiff-backup/rdiff-backup/releases/download/v2.0.5/rdiff-backup-2.0.5.win32exe.zip 17 | 18 | - name: Decompress 19 | uses: TonyBogdanov/zip@1.0 20 | with: 21 | args: unzip ./rdiff-backup-2.0.5.win32exe.zip -d . 22 | 23 | - name: Copy rdiff-backup to place 24 | run: | 25 | cp ./rdiff-backup-2.0.5/rdiff-backup.exe ./src/rdiff-backup.exe 26 | - run: sudo apt-get update && sudo apt install -y p7zip-full file gawk wget 27 | 28 | - name: extract ssh.exe and deps 29 | working-directory: ./src 30 | run: | 31 | bash -x build-scripts/get_ssh_bin 32 | 33 | - name: Copy requirements.txt to place 34 | run: | 35 | cp ./requirements.txt ./src/requirements.txt 36 | 37 | 38 | - name: Package Application 39 | uses: JackMcKew/pyinstaller-action-windows@main 40 | with: 41 | path: src 42 | 43 | - uses: actions/upload-artifact@v2 44 | with: 45 | name: backupfriend-client-win64 46 | path: src/dist/windows 47 | -------------------------------------------------------------------------------- /.github/workflows/pypi.yaml: -------------------------------------------------------------------------------- 1 | name: Build python package 2 | 3 | on: 4 | push: 5 | pull_request: 6 | release: 7 | types: [published] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | build: 12 | name: 🔨 Build distribution 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v2 16 | with: 17 | fetch-depth: 0 18 | - name: 🏗 Set up Python 3.7 19 | uses: actions/setup-python@v1 20 | with: 21 | python-version: 3.7 22 | - name: 🏗 Install build dependencies 23 | run: | 24 | python -m pip install wheel --user 25 | - name: 🔨 Build a binary wheel and a source tarball 26 | run: | 27 | python setup.py sdist bdist_wheel 28 | - name: ⬆ Upload build result 29 | uses: actions/upload-artifact@v1 30 | with: 31 | name: dist 32 | path: dist 33 | publish-on-testpypi: 34 | name: 📦 Publish on TestPyPI 35 | if: github.event_name == 'release' 36 | runs-on: ubuntu-latest 37 | steps: 38 | - name: ⬇ Download build result 39 | uses: actions/download-artifact@v1 40 | with: 41 | name: dist 42 | path: dist 43 | - name: 📦 Publish to index 44 | uses: pypa/gh-action-pypi-publish@master 45 | continue-on-error: true 46 | with: 47 | user: __token__ 48 | password: ${{ secrets.testpypi_password }} 49 | repository_url: https://test.pypi.org/legacy/ 50 | 51 | publish-on-pypi: 52 | name: 📦 Publish tagged releases to PyPI 53 | if: github.event_name == 'release' 54 | needs: publish-on-testpypi 55 | runs-on: ubuntu-latest 56 | steps: 57 | - name: ⬇ Download build result 58 | uses: actions/download-artifact@v1 59 | with: 60 | name: dist 61 | path: dist 62 | - name: 📦 Publish to index 63 | uses: pypa/gh-action-pypi-publish@master 64 | with: 65 | user: __token__ 66 | password: ${{ secrets.pypi_password }} 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Python template 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | pip-wheel-metadata/ 26 | share/python-wheels/ 27 | *.egg-info/ 28 | .installed.cfg 29 | *.egg 30 | MANIFEST 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .nox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *.cover 52 | *.py,cover 53 | .hypothesis/ 54 | .pytest_cache/ 55 | cover/ 56 | 57 | # Translations 58 | *.mo 59 | *.pot 60 | 61 | # Django stuff: 62 | *.log 63 | local_settings.py 64 | db.sqlite3 65 | db.sqlite3-journal 66 | 67 | # Flask stuff: 68 | instance/ 69 | .webassets-cache 70 | 71 | # Scrapy stuff: 72 | .scrapy 73 | 74 | # Sphinx documentation 75 | docs/_build/ 76 | 77 | # PyBuilder 78 | .pybuilder/ 79 | target/ 80 | 81 | # Jupyter Notebook 82 | .ipynb_checkpoints 83 | 84 | # IPython 85 | profile_default/ 86 | ipython_config.py 87 | 88 | # pyenv 89 | # For a library or package, you might want to ignore these files since the code is 90 | # intended to run in multiple environments; otherwise, check them in: 91 | # .python-version 92 | 93 | # pipenv 94 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 95 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 96 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 97 | # install all needed dependencies. 98 | #Pipfile.lock 99 | 100 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 101 | __pypackages__/ 102 | 103 | # Celery stuff 104 | celerybeat-schedule 105 | celerybeat.pid 106 | 107 | # SageMath parsed files 108 | *.sage.py 109 | 110 | # Environments 111 | .env 112 | .venv 113 | env/ 114 | venv/ 115 | ENV/ 116 | env.bak/ 117 | venv.bak/ 118 | 119 | # Spyder project settings 120 | .spyderproject 121 | .spyproject 122 | 123 | # Rope project settings 124 | .ropeproject 125 | 126 | # mkdocs documentation 127 | /site 128 | 129 | # mypy 130 | .mypy_cache/ 131 | .dmypy.json 132 | dmypy.json 133 | 134 | # Pyre type checker 135 | .pyre/ 136 | 137 | # pytype static type analyzer 138 | .pytype/ 139 | 140 | # Cython debug symbols 141 | cython_debug/ 142 | 143 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | BackupFriend Client 2 | =================== 3 | 4 | BackupFriend is a tool that lets you place a RaspberryPi with a hard drive in your friends house or family, or a server. And lets you sync your folders tracking history changes. 5 | It uses a backend located here: https://github.com/guysoft/BackupFriend-docker . And a RaspsberryPi distro that holds this backend here: https://github.com/guysoft/BackupFriendPi 6 | 7 | This repository is the graphical Desktop application. 8 | 9 | Requiremnets: 10 | - SSH 11 | - rdiff-backup 12 | 13 | 14 | Screenshots 15 | =========== 16 | 17 | .. image:: https://raw.githubusercontent.com/guysoft/backupfriend-client/master/media/backfriend-client-screenshot.png 18 | .. :scale: 25https://raw.githubusercontent.com/guysoft/backupfriend-client/master/media/backfriend-client-screenshot.png % 19 | .. :alt: Main window 20 | 21 | Donate 22 | ------ 23 | BackupFriend is 100% free and open source and maintained by Guy Sheffer. If its helping your life, your organisation or makes you happy, please consider making a donation. It means I can code more and worry less about my balance. Any amount counts. 24 | 25 | |paypal| 26 | 27 | .. |paypal| image:: https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif 28 | :target: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=26VJ9MSBH3V3W&source=url 29 | 30 | Install 31 | ======= 32 | 33 | Linux 34 | ----- 35 | 36 | Install depdenceies and package:: 37 | 38 | sudo apt-get install build-essential libgtk-3-dev librsync-dev 39 | sudo pip3 install git+https://github.com/guysoft/backupfriend-client 40 | 41 | Mac 42 | --- 43 | 44 | 45 | Install the package:: 46 | 47 | sudo pip3 install git+https://github.com/guysoft/backupfriend-client 48 | 49 | Windows 50 | ------- 51 | 52 | There is a package built in github actions you can download an extract. 53 | When the inital release is done it will be avilable the relase tag. 54 | You can find them here the bottom of the page of each run: 55 | https://github.com/guysoft/backupfriend-client/actions/workflows/main.yaml 56 | 57 | Build and develop 58 | ================= 59 | 60 | 1. Clone this repo:: 61 | 62 | git clone https://github.com/guysoft/backupfriend-client.git 63 | 64 | 65 | 2. Install requirements:: 66 | 67 | cd backupfriend-client 68 | pip3 install requirements.txt 69 | 70 | 3. Run: :: 71 | 72 | python3 src/backupfriend-client.py 73 | 74 | 75 | Windows note: 76 | - You will need rdiff-backup executable from here: https://github.com/rdiff-backup/rdiff-backup/releases/tag/v2.0.5 77 | - You need ssh from here: http://www.mls-software.com/opensshd.html 78 | 79 | Atribution: 80 | Icon by: Freepik: https://www.flaticon.com/authors/freepik 81 | -------------------------------------------------------------------------------- /media/backfriend-client-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guysoft/backupfriend-client/c45c4b0a2442e0f1cea77fceb67dbc3e3fbb8315/media/backfriend-client-screenshot.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | wxPython 2 | PyYAML 3 | schedule 4 | appdirs 5 | cryptography 6 | pypubsub 7 | requests 8 | packaging 9 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | import sys 3 | from src.backupfriend.__init__ import __version__ as version 4 | 5 | with open("README.rst", "r") as fh: 6 | long_description = fh.read() 7 | 8 | P2APP_OPTIONS = { 9 | 'argv_emulation': False, 10 | 'site_packages': True, 11 | #'iconfile': 'appicon.icns', 12 | 'packages': ["schedule", "encodings", "wx", "requests", "packaging", 13 | "appdirs", "cryptography", "rdiff_backup"], 14 | 'plist': { 15 | 'CFBundleName': 'BackupFriend', 16 | 'CFBundleDisplayName': 'BackupFriend', 17 | 'LSUIElement': False, 18 | }, 19 | 'iconfile': 'src/backupfriend/images/icon.icns', 20 | 'extra_scripts': ["/usr/local/bin/rdiff-backup"] 21 | } 22 | install_requires=[ 23 | "wxPython", "PyYAML", "schedule", 'dataclasses;python_version<"3.7"', "appdirs", "rdiff-backup", "cryptography", "pypubsub", "requests", "packaging"] 24 | 25 | if sys.platform == "darwin": 26 | install_requires = ["wxPython", "schedule", "appdirs", "cryptography", "pypubsub", "pyyaml", "requests", "packaging"] 27 | 28 | 29 | setuptools.setup( 30 | name="backupfriend", 31 | version=version, 32 | description="Read the latest Real Python tutorials", 33 | long_description=long_description, 34 | long_description_content_type="text/x-rst", 35 | url="https://github.com/guysoft/BackupFriend", 36 | author="Guy Sheffer", 37 | author_email="gusyoft@gmail.com", 38 | license="GPLv3", 39 | py_modules=["backupfriendclient"], 40 | classifiers=[ 41 | "License :: OSI Approved :: MIT License", 42 | "Programming Language :: Python", 43 | "Programming Language :: Python :: 3", 44 | ], 45 | packages=setuptools.find_packages(where="src"), 46 | package_dir={ 47 | "": "src", 48 | }, 49 | data_files=[('images', ['src/backupfriend/images/icon.png']), 50 | ('config', ['src/backupfriend/config/config.yml', 'src/backupfriend/config/config-osx.yml', 'src/backupfriend/config/config-windows.yml']), 51 | ('res', ['src/backupfriend/res/main.xrc'])], 52 | include_package_data=True, 53 | install_requires=install_requires, 54 | entry_points={"console_scripts": ["backupfriend=backupfriendclient:run"]}, 55 | app=['src/backupfriend-client.py'], 56 | options={'py2app': P2APP_OPTIONS}, 57 | setup_requires=['py2app'], 58 | ) 59 | -------------------------------------------------------------------------------- /src/backupfriend-client.py: -------------------------------------------------------------------------------- 1 | def run(): 2 | import wx 3 | from backupfriend.main import main 4 | # Needed so pyinstaller will detect it needs this module 5 | import backupfriend.sub 6 | 7 | print(backupfriend) 8 | 9 | main() 10 | return 11 | 12 | if __name__ == "__main__": 13 | run() 14 | -------------------------------------------------------------------------------- /src/backupfriend-client.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | 3 | block_cipher = None 4 | 5 | 6 | a = Analysis(['backupfriend-client.py'], 7 | binaries=[('rdiff-backup.exe', 'bin'), ('ssh_bin/ssh.exe', 'bin'), ('ssh_bin/cygattr-1.dll', 'bin'), ('ssh_bin/cygcom_err-2.dll', 'bin'), ('ssh_bin/cygcrypt-2.dll', 'bin'), ('ssh_bin/cygcrypto-1.1.dll', 'bin'), ('ssh_bin/cygedit-0.dll', 'bin'), ('ssh_bin/cyggcc_s-seh-1.dll', 'bin'), ('ssh_bin/cyggssapi_krb5-2.dll', 'bin'), ('ssh_bin/cygiconv-2.dll', 'bin'), ('ssh_bin/cygintl-8.dll', 'bin'), ('ssh_bin/cygk5crypto-3.dll', 'bin'), ('ssh_bin/cygkrb5-3.dll', 'bin'), ('ssh_bin/cygkrb5support-0.dll', 'bin'), ('ssh_bin/cyglsa64.dll', 'bin'), ('ssh_bin/cygncursesw-10.dll', 'bin'), ('ssh_bin/cygreadline7.dll', 'bin'), ('ssh_bin/cygssp-0.dll', 'bin'), ('ssh_bin/cygwin1.dll', 'bin'), ('ssh_bin/cygz.dll', 'bin')], 8 | datas=[('backupfriend\\config', 'backupfriend\\config'), ('backupfriend\\images', 'backupfriend\\images'), ('backupfriend\\res', 'backupfriend\\res')], 9 | hiddenimports=[], 10 | hookspath=[], 11 | runtime_hooks=[], 12 | excludes=[], 13 | win_no_prefer_redirects=False, 14 | win_private_assemblies=False, 15 | cipher=block_cipher, 16 | noarchive=False) 17 | pyz = PYZ(a.pure, a.zipped_data, 18 | cipher=block_cipher) 19 | exe = EXE(pyz, 20 | a.scripts, 21 | [], 22 | exclude_binaries=True, 23 | name='backupfriend-client', 24 | debug=False, 25 | bootloader_ignore_signals=False, 26 | strip=False, 27 | upx=True, 28 | console=False ) 29 | coll = COLLECT(exe, 30 | a.binaries, 31 | a.zipfiles, 32 | a.datas, 33 | strip=False, 34 | upx=True, 35 | upx_exclude=[], 36 | name='backupfriend-client') 37 | -------------------------------------------------------------------------------- /src/backupfriend/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.2.0" 2 | -------------------------------------------------------------------------------- /src/backupfriend/common.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from appdirs import user_data_dir 4 | import requests 5 | 6 | GITHUB_URL = "https://github.com/guysoft/backupfriend-client" 7 | GITHUB_API = "https://api.github.com/repos/guysoft/backupfriend-client" 8 | 9 | def ensure_dir(d, chmod=0o777): 10 | """ 11 | Ensures a folder exists. 12 | Returns True if the folder already exists 13 | """ 14 | if not os.path.exists(d): 15 | os.makedirs(d, chmod) 16 | os.chmod(d, chmod) 17 | return False 18 | return True 19 | 20 | 21 | def get_data_path(): 22 | appname = "BackupFriend" 23 | appauthor = "Guy Sheffer (GuySoft)" 24 | 25 | if "linux" in sys.platform: 26 | DATA_PATH = os.path.expanduser(os.path.join("~", ".backupfriend")) 27 | else: 28 | DATA_PATH = user_data_dir(appname, appauthor) 29 | return DATA_PATH 30 | 31 | 32 | def resource_path(): 33 | """ Get absolute path to resource, works for dev and for PyInstaller """ 34 | print("getting base path") 35 | base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__))) 36 | print(base_path) 37 | return base_path 38 | 39 | 40 | def get_latest_version(): 41 | """ 42 | Get latest version, none if no version found 43 | """ 44 | try: 45 | response = requests.get(GITHUB_API + "/tags") 46 | data = response.json()[0] 47 | if "name" in data: 48 | return data["name"] 49 | except Exception: 50 | return 51 | return 52 | -------------------------------------------------------------------------------- /src/backupfriend/config/config-osx.yml: -------------------------------------------------------------------------------- 1 | main: 2 | bin: "__app_bin_path__/rdiff-backup" 3 | # bin: "echo" 4 | backups: 5 | - name: "example" 6 | source: "/private/tmp" 7 | dest: "user@backupfriend::/backup/media/usb/example" 8 | port: "8022" 9 | key: "__user_data__/id_rsa" 10 | server_username: admin 11 | server_url: http://backupfriend 12 | every: "daily" 13 | time: "08:00" 14 | -------------------------------------------------------------------------------- /src/backupfriend/config/config-windows.yml: -------------------------------------------------------------------------------- 1 | main: 2 | bin: "__package_path__\\bin\\rdiff-backup.exe" 3 | ssh: "__package_path__\\bin\\ssh.exe" 4 | backups: 5 | - name: "example" 6 | source: "C:\\Windows\\Temp" 7 | dest: "user@backupfriend::/backup/media/usb/example" 8 | port: "8022" 9 | key: "__user_data__\\id_rsa" 10 | server_username: admin 11 | server_url: http://backupfriend 12 | every: "daily" 13 | time: "08:00" 14 | -------------------------------------------------------------------------------- /src/backupfriend/config/config.yml: -------------------------------------------------------------------------------- 1 | main: 2 | bin: __app_bin_path__/rdiff-backup 3 | # bin: "echo" 4 | backups: 5 | - name: "example" 6 | source: "/tmp" 7 | dest: "user@backupfriend::/backup/media/usb/example" 8 | port: "8022" 9 | key: "__user_data__/id_rsa" 10 | server_username: admin 11 | server_url: http://backupfriend 12 | every: "daily" 13 | time: "08:00" 14 | -------------------------------------------------------------------------------- /src/backupfriend/images/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guysoft/backupfriend-client/c45c4b0a2442e0f1cea77fceb67dbc3e3fbb8315/src/backupfriend/images/icon.icns -------------------------------------------------------------------------------- /src/backupfriend/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guysoft/backupfriend-client/c45c4b0a2442e0f1cea77fceb67dbc3e3fbb8315/src/backupfriend/images/icon.png -------------------------------------------------------------------------------- /src/backupfriend/main.py: -------------------------------------------------------------------------------- 1 | import wx.adv 2 | import wx 3 | from wx import MenuBar, Panel, WindowList 4 | import sys 5 | from wx import xrc 6 | import yaml 7 | import os 8 | import schedule 9 | from dataclasses import dataclass 10 | import subprocess 11 | import time 12 | from backupfriend.common import get_data_path, ensure_dir, resource_path, get_latest_version, GITHUB_URL 13 | from backupfriend import __version__ as VERSION 14 | from collections.abc import Iterable 15 | import wx.lib.inspection 16 | import shutil 17 | import shlex 18 | from pubsub import pub 19 | from shlex import quote 20 | import webbrowser 21 | import traceback 22 | from packaging import version 23 | import locale 24 | 25 | def get_os(): 26 | if sys.platform.startswith("win"): 27 | return "windows" 28 | elif sys.platform == "darwin": 29 | return "osx" 30 | elif sys.platform == "linux": 31 | return "linux" 32 | else: 33 | return "unkonwn" 34 | 35 | APP_PATH = os.path.join(os.path.dirname(__file__)) 36 | 37 | # OS X app bin path. 38 | APP_BIN_PATH = None 39 | if get_os() == "osx": 40 | if not __file__.endswith(".py"): 41 | APP_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) 42 | APP_BIN_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "MacOS")) 43 | 44 | TRAY_ICON = os.path.join(APP_PATH, "images", 'icon.png') 45 | TRAY_TOOLTIP = 'BackupFriend' 46 | CFG_UPDATE_MSG = "config_update" 47 | START_JOB_MSG = "job_start" 48 | END_JOB_MSG = "job_end" 49 | 50 | # TODO: 51 | # 1. Make settings window 52 | 53 | debug = 'DEBUG' in os.environ and os.environ['DEBUG'] == "on" 54 | 55 | DATA_PATH = get_data_path() 56 | 57 | 58 | if get_os() == "windows": 59 | CONFIG_PATH_DEFAULT = os.path.join(os.path.dirname(__file__), "config", "config-windows.yml") 60 | elif get_os() == "osx": 61 | CONFIG_PATH_DEFAULT = os.path.join(APP_PATH, "config", "config-osx.yml") 62 | else: 63 | CONFIG_PATH_DEFAULT = os.path.join(os.path.dirname(__file__), "config", "config.yml") 64 | CONFIG_PATH = os.path.join(DATA_PATH, "config", "config.yml") 65 | 66 | 67 | def get_config(): 68 | if not os.path.isfile(CONFIG_PATH): 69 | ensure_dir(os.path.dirname(CONFIG_PATH)) 70 | shutil.copy(CONFIG_PATH_DEFAULT, CONFIG_PATH) 71 | with open(CONFIG_PATH) as f: 72 | return yaml.load(f, Loader=yaml.FullLoader) 73 | return 74 | 75 | def save_config(): 76 | with open(CONFIG_PATH, 'w') as f: 77 | yaml.safe_dump(config, f) 78 | 79 | config = get_config() 80 | 81 | if "ssh" not in config["main"] and not get_os() == "windows": 82 | ssh = subprocess.run(['which', 'ssh'], capture_output=True, text=True).stdout.strip() 83 | config["main"]["ssh"] = ssh 84 | save_config() 85 | 86 | def _run_command(command, **kwargs): 87 | is_timeout = False 88 | if debug: 89 | print(" ".join(command)) 90 | p = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) 91 | try: 92 | stdout, stderr = p.communicate(timeout=5) 93 | except subprocess.TimeoutExpired as e: 94 | p.kill() 95 | stdout,stderr = p.communicate() 96 | is_timeout = True 97 | try: 98 | stdout = stdout.decode("utf-8") 99 | except UnicodeDecodeError as e: 100 | print("Error: can't decode stdout") 101 | print(e) 102 | print(stdout) 103 | stdout = "" 104 | 105 | try: 106 | stderr = stderr.decode("utf-8") 107 | except UnicodeDecodeError as e: 108 | print("Error: can't decode stderr") 109 | print(stderr) 110 | print(e) 111 | stderr = "" 112 | 113 | return_value = [stdout, stderr, is_timeout] 114 | return return_value 115 | 116 | 117 | def create_menu_item(menu, label, func): 118 | item = wx.MenuItem(menu, -1, label) 119 | menu.Bind(wx.EVT_MENU, func, id=item.GetId()) 120 | menu.Append(item) 121 | return item 122 | 123 | 124 | class Settings(wx.Dialog): 125 | def __init__(self, settings, *args, **kwargs): 126 | wx.Dialog.__init__(self, *args, **kwargs) 127 | self.settings = settings 128 | 129 | self.panel = wx.Panel(self) 130 | self.button_ok = wx.Button(self.panel, label="OK") 131 | self.button_cancel = wx.Button(self.panel, label="Cancel") 132 | self.button_ok.Bind(wx.EVT_BUTTON, self.onOk) 133 | self.button_cancel.Bind(wx.EVT_BUTTON, self.onCancel) 134 | 135 | self.checkboxes = [] 136 | for i in range(3): 137 | checkbox = wx.CheckBox(self.panel, label=str(i)) 138 | checkbox.SetValue(self.settings[i]) 139 | self.checkboxes.append(checkbox) 140 | 141 | self.sizer = wx.BoxSizer() 142 | for checkbox in self.checkboxes: 143 | self.sizer.Add(checkbox) 144 | self.sizer.Add(self.button_ok) 145 | self.sizer.Add(self.button_cancel) 146 | 147 | self.panel.SetSizerAndFit(self.sizer) 148 | 149 | def onCancel(self, e): 150 | self.EndModal(wx.ID_CANCEL) 151 | 152 | def onOk(self, e): 153 | for i in range(3): 154 | self.settings[i] = self.checkboxes[i].GetValue() 155 | self.EndModal(wx.ID_OK) 156 | 157 | def GetSettings(self): 158 | return self.settings 159 | 160 | 161 | class SettingsFrame(wx.Frame): 162 | """ 163 | Class used for creating frames other than the main one 164 | """ 165 | 166 | def __init__(self, title, parent=None): 167 | wx.Frame.__init__(self, parent=parent, title=title) 168 | self.Bind(wx.EVT_CLOSE, self.onClose) 169 | self.Centre() 170 | self.Show() 171 | if debug: 172 | print(self.sync_jobs) 173 | ## End Window init stuff ## 174 | 175 | self.panel = wx.Panel(self) 176 | self.button_ok = wx.Button(self.panel, label="OK") 177 | self.button_cancel = wx.Button(self.panel, label="Cancel") 178 | 179 | self.checkboxes = [] 180 | for i in range(3): 181 | checkbox = wx.CheckBox(self.panel, label=str(i)) 182 | self.checkboxes.append(checkbox) 183 | 184 | self.sizer = wx.BoxSizer() 185 | for checkbox in self.checkboxes: 186 | self.sizer.Add(checkbox) 187 | self.sizer.Add(self.button_ok) 188 | self.sizer.Add(self.button_cancel) 189 | 190 | self.panel.SetSizerAndFit(self.sizer) 191 | 192 | # print(wx.geta.sync_jobs) 193 | 194 | def onClose(self, event): 195 | """""" 196 | print("closing") 197 | # TODO - also delete from memmory 198 | # self.Hide() 199 | self.Destroy() 200 | # print(self) 201 | 202 | 203 | def get_object_by_id(panel, xrc, name, actual_id=None, child_current_level=None): 204 | if actual_id is None: 205 | actual_id = xrc.XRCID(name) 206 | 207 | # First recursion 208 | if child_current_level is None: 209 | child_current_level = panel.GetChildren() 210 | 211 | if hasattr(child_current_level, 'GetId') and child_current_level.GetId() == actual_id: 212 | print("WEWEADBaSIDA") 213 | return child_current_level 214 | 215 | if type(child_current_level) != WindowList: 216 | print(child_current_level.GetName()) 217 | else: 218 | print(child_current_level) 219 | # sys.exit() 220 | 221 | if isinstance(child_current_level, Iterable): 222 | print('bo') 223 | for child in child_current_level: 224 | widget = child 225 | if widget.GetId() == actual_id: 226 | print("WEWEADBaSIDA") 227 | sys.exit() 228 | return widget 229 | 230 | # item = get_object_by_id(panel, xrc, name, actual_id, child) 231 | 232 | if item is not None: 233 | print("AWDEADNaSN") 234 | # return item 235 | 236 | 237 | class MainFrame(wx.Frame): 238 | """ 239 | Class used for creating frames other than the main one 240 | """ 241 | 242 | def __init__(self, title=None): 243 | # Sync control logic 244 | self.sync_jobs = [] 245 | self.add_backups(config["backups"], True) 246 | # self.Bind(wx.EVT_IDLE, self.OnIdle) 247 | self.on_timer() 248 | 249 | 250 | self.res = xrc.XmlResource(os.path.join(APP_PATH, "res", 'main.xrc')) 251 | 252 | wx.Frame.__init__(self, parent=None, title=title) 253 | self.SetSize((1000, 700)) 254 | icon = wx.Icon() 255 | icon.CopyFromBitmap(wx.Bitmap(TRAY_ICON, wx.BITMAP_TYPE_ANY)) 256 | self.SetIcon(icon) 257 | 258 | self.menuBar = self.res.LoadMenuBar("m_menubar1") 259 | self.panel = self.res.LoadPanel(self, "MainPanel") 260 | self.panel.SetLayoutDirection(wx.Layout_LeftToRight) 261 | self.SetLayoutDirection(wx.Layout_LeftToRight) 262 | 263 | # Menu Logic 264 | self.SetMenuBar(self.menuBar) 265 | self.Bind(wx.EVT_MENU, self.exit, id=xrc.XRCID('m_exit')) 266 | self.Bind(wx.EVT_MENU, self.show_public_key, id=xrc.XRCID('m_show_public_key')) 267 | self.Bind(wx.EVT_MENU, self.start_first_time_wizard, id=xrc.XRCID('m_generate_keys')) 268 | self.Bind(wx.EVT_MENU, self.check_updates, id=xrc.XRCID('m_check_updates')) 269 | self.Bind(wx.EVT_MENU, self.show_about, id=xrc.XRCID('m_about')) 270 | 271 | self.Bind(wx.EVT_MENU, self.open_settings, id=xrc.XRCID('m_settings')) 272 | self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.select_backup, id=xrc.XRCID('m_list_syncs')) 273 | self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.deselect_backup, id=xrc.XRCID('m_list_syncs')) 274 | self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.select_run, id=xrc.XRCID('m_list_runs')) 275 | 276 | self.Bind(wx.EVT_CLOSE, self.onClose) 277 | 278 | # Buttons 279 | self.m_run_btn = xrc.XRCCTRL(self.panel, "m_run") 280 | self.m_edit_btn = xrc.XRCCTRL(self.panel, "m_edit") 281 | self.m_delete_btn = xrc.XRCCTRL(self.panel, "m_delete") 282 | self.m_go_to_server_btn = xrc.XRCCTRL(self.panel, "m_go_to_server") 283 | 284 | self.Bind(wx.EVT_BUTTON, self.run_job, self.m_run_btn) 285 | self.Bind(wx.EVT_BUTTON, self.show_edit_dialog, self.m_edit_btn) 286 | self.Bind(wx.EVT_BUTTON, self.delete_job, self.m_delete_btn) 287 | self.Bind(wx.EVT_BUTTON, self.go_to_server, self.m_go_to_server_btn) 288 | self.Bind(wx.EVT_BUTTON, self.show_create_dialog, id=xrc.XRCID('m_add')) 289 | 290 | self.Centre() 291 | self.Show() 292 | 293 | def is_first_run(): 294 | return not os.path.isfile(os.path.join(DATA_PATH, "id_rsa")) 295 | 296 | if is_first_run(): 297 | self.start_first_time_wizard() 298 | 299 | 300 | if not is_first_run(): 301 | self.Hide() 302 | 303 | self.m_log_label = xrc.XRCCTRL(self.panel, 'm_log_label') 304 | 305 | # wx.lib.inspection.InspectionTool().Show() 306 | 307 | ## End Window init stuff ## 308 | 309 | # print(len(self.sync_jobs)) 310 | 311 | self.m_console = xrc.XRCCTRL(self.panel, 'm_console') 312 | 313 | self.m_list_syncs = xrc.XRCCTRL(self.panel, 'm_list_syncs') 314 | self.m_list_syncs.data_keys = ["name", "dest", "every", "time"] 315 | 316 | self.m_list_runs = xrc.XRCCTRL(self.panel, 'm_list_runs') 317 | self.m_list_runs.data_keys = ["id", "Time Ran"] 318 | 319 | for i, key in enumerate(self.m_list_runs.data_keys): 320 | self.m_list_runs.InsertColumn(i, key) 321 | 322 | for i, key in enumerate(self.m_list_syncs.data_keys): 323 | self.m_list_syncs.InsertColumn(i, key) 324 | 325 | self.update_list_sync() 326 | pub.subscribe(self.update_list_sync, CFG_UPDATE_MSG) 327 | pub.subscribe(self.update_start_job, START_JOB_MSG) 328 | pub.subscribe(self.update_end_job, END_JOB_MSG) 329 | 330 | # print(wx.geta.sync_jobs) 331 | 332 | # Sync functions logic 333 | def add_backups(self, backups_list, in_config=False): 334 | jobs_names = list(map(lambda backup: backup.name, self.sync_jobs)) 335 | 336 | for backup in backups_list: 337 | # Sanity_check 338 | if backup["name"] in jobs_names: 339 | raise ValueError(f"Job with the name '{backup['name']}' already exists") 340 | if backup["name"] == "": 341 | raise ValueError("Name can't be empty") 342 | if backup["source"] == "": 343 | raise ValueError("Source can't be empty") 344 | if backup["dest"] == "": 345 | raise ValueError("Destination can't be empty") 346 | 347 | backup["key"] = os.path.expanduser(backup["key"]) 348 | backup["source"] = os.path.expanduser(backup["source"]) 349 | 350 | # Fix missing fields from older builds 351 | for item in ["server_url", "server_username"]: 352 | if item not in backup: 353 | backup[item] = "" 354 | 355 | if not in_config: 356 | config["backups"].append(backup) 357 | backup_class = Backup(**backup, window=self, test_dummy=False) 358 | self.sync_jobs.append(backup_class) 359 | 360 | if not in_config: 361 | save_config() 362 | 363 | pub.sendMessage(CFG_UPDATE_MSG) 364 | 365 | def delete_backup(self, backup_name): 366 | try: 367 | del_index = next( 368 | i for i, elem in enumerate(config["backups"]) if elem["name"] == backup_name) 369 | config["backups"].pop(del_index) 370 | 371 | del_index = next( 372 | i for i, elem in enumerate(self.sync_jobs) if elem.name == backup_name) 373 | self.sync_jobs.pop(del_index) 374 | except StopIteration: 375 | print(f"Error: no backup named {backup_name}") 376 | 377 | with open(CONFIG_PATH, 'w') as f: 378 | yaml.dump(config, f) 379 | 380 | run_dir = os.path.join(DATA_PATH, "jobs_data", backup_name) 381 | if os.path.isdir(run_dir): 382 | shutil.rmtree(run_dir) 383 | 384 | pub.sendMessage(CFG_UPDATE_MSG) 385 | 386 | def update_backup(self, backup_name, edit_dict): 387 | config_index = next( 388 | i for i, elem in enumerate(config["backups"]) if elem["name"] == backup_name) 389 | 390 | jobs_index = next( 391 | i for i, elem in enumerate(self.sync_jobs) if elem.name == backup_name) 392 | 393 | for key, val in edit_dict.items(): 394 | if key=="name": 395 | jobs_names = list(map(lambda backup: 396 | backup.name if backup.name != backup_name else '', 397 | self.sync_jobs)) 398 | if val in jobs_names: 399 | raise ValueError(f"'{val}' is alredy exist") 400 | 401 | # rename the run dir 402 | old_run_dir = os.path.join(DATA_PATH, "jobs_data", 403 | config["backups"][config_index]["name"]) 404 | new_run_dir = os.path.join(DATA_PATH, "jobs_data", val) 405 | if os.path.isdir(old_run_dir): 406 | os.rename(old_run_dir, new_run_dir) 407 | 408 | config["backups"][config_index][key] = val 409 | self.sync_jobs[jobs_index].__dict__[key] = val 410 | 411 | with open(CONFIG_PATH, 'w') as f: 412 | yaml.dump(config, f) 413 | 414 | pub.sendMessage(CFG_UPDATE_MSG) 415 | 416 | def get_backup_by_name(self, backup_name): 417 | job_index = next( 418 | i for i, elem in enumerate(self.sync_jobs) if elem.name == backup_name) 419 | 420 | return self.sync_jobs[job_index] 421 | 422 | def on_timer(self): 423 | # wx.CallLater(1000 * 60, self.on_timer) 424 | wx.CallLater(1000, self.on_timer) 425 | schedule.run_pending() 426 | if self.sync_jobs is not None: 427 | for sync_job in self.sync_jobs: 428 | if sync_job.process_object is not None: 429 | if sync_job.process_object.terminated: 430 | print("terminated") 431 | # TODO: Parse output and mark success False on fail 432 | pub.sendMessage(END_JOB_MSG, name=sync_job.name, success=True) 433 | 434 | stream = sync_job.process_object.GetInputStream() 435 | 436 | while stream is not None and stream.CanRead(): 437 | text = stream.read() 438 | sync_job.update_log(text) 439 | 440 | print(text.decode()) 441 | 442 | stream_err = sync_job.process_object.GetErrorStream() 443 | 444 | while stream_err is not None and stream_err.CanRead(): 445 | text = stream_err.read() 446 | sync_job.update_log(text) 447 | 448 | sync_job.process_object = None 449 | else: 450 | try: 451 | stream = sync_job.process_object.GetInputStream() 452 | 453 | while stream is not None and stream.CanRead(): 454 | text = stream.read() 455 | sync_job.update_log(text) 456 | 457 | print(text.decode()) 458 | 459 | stream_err = sync_job.process_object.GetErrorStream() 460 | 461 | while stream_err is not None and stream_err.CanRead(): 462 | text = stream_err.read() 463 | sync_job.update_log(text) 464 | 465 | print(text.decode()) 466 | except RuntimeError as e: 467 | print(e) 468 | # import code; 469 | # code.interact(local=dict(globals(), **locals())) 470 | 471 | # print("Done idle") 472 | 473 | def get_job_by_name(self, name): 474 | for job in self.sync_jobs: 475 | if debug: 476 | print(job.name) 477 | print(name) 478 | if job.name == name: 479 | return job 480 | return 481 | # End sync functions logic 482 | 483 | def select_backup(self, event): 484 | item = event.GetItem() 485 | job_name = item.GetText() 486 | self.current_job = job_name 487 | self.display_job(job_name) 488 | 489 | self.m_run_btn.Enable() 490 | self.m_edit_btn.Enable() 491 | self.m_delete_btn.Enable() 492 | self.m_go_to_server_btn.Enable() 493 | 494 | return 495 | 496 | def deselect_backup(self, event): 497 | self.current_job = None 498 | 499 | self.m_run_btn.Disable() 500 | self.m_edit_btn.Disable() 501 | self.m_delete_btn.Disable() 502 | 503 | def run_job(self, event): 504 | if debug: 505 | print("Running: " + str(self.current_job)) 506 | job = self.get_job_by_name(self.current_job) 507 | if not job.running(): 508 | job.run_backup() 509 | else: 510 | print("Job already running") 511 | wx.MessageDialog(self, 'Job "' + job.name + '" already running', caption="Job already running", 512 | style=wx.OK|wx.CENTRE, pos=wx.DefaultPosition).ShowModal() 513 | 514 | 515 | def delete_job(self, event): 516 | dialog = self.res.LoadDialog(self, 'delete_job_dialog') 517 | dialog.ShowModal(job_name=self.current_job) 518 | self.current_job = None 519 | 520 | return 521 | 522 | def go_to_server(self, event): 523 | job = self.get_job_by_name(self.current_job) 524 | print(job.server_url) 525 | print(job.server_username) 526 | dest = job.dest.split("::")[1] 527 | dest = "/".join(dest.split("/")[2:]) 528 | 529 | url = job.server_url + "/browse/" + job.server_username + "/" + dest 530 | if debug: 531 | print(url) 532 | webbrowser.open(url) 533 | return 534 | 535 | 536 | def start_first_time_wizard(self, event=None): 537 | wizard = self.res.LoadObject(None, 'first_run_wizard', 'wxWizard') 538 | page1 = wx.xrc.XRCCTRL(wizard, 'm_wizPage1') 539 | wizard.RunWizard(page1) 540 | 541 | def select_run(self, event): 542 | self.current_run = event.Index 543 | item = event.GetItem() 544 | run_name = item.GetText() 545 | if debug: 546 | print("Selected run: " + run_name) 547 | self.display_run(self.current_job, run_name) 548 | 549 | def display_job(self, job_name): 550 | self.m_list_runs.DeleteAllItems() 551 | self.m_console.SetValue("") 552 | job = self.get_job_by_name(job_name) 553 | 554 | for i, file_name in enumerate(job.get_log_files()): 555 | self.m_list_runs.InsertItem(i, job.name) 556 | if debug: 557 | print(i, file_name) 558 | self.m_list_runs.SetItem(i, self.m_list_runs.data_keys.index("id"), file_name) 559 | self.m_list_runs.SetItem(i, self.m_list_runs.data_keys.index("Time Ran"), job.get_run_created(file_name)) 560 | self.m_list_runs.resizeLastColumn(0) 561 | 562 | return 563 | 564 | def display_run(self, job_name, run_name): 565 | self.m_console.SetValue("") 566 | job = self.get_job_by_name(job_name) 567 | if job is not None: 568 | log = job.get_log(run_name) 569 | self.m_console.SetValue(log) 570 | else: 571 | self.m_console.SetValue("Log not generated") 572 | return 573 | 574 | def update_list_sync(self): 575 | items_num = self.m_list_syncs.GetItemCount() 576 | sync_jobs_list = list(self.sync_jobs) 577 | self.m_list_syncs.DeleteAllItems() 578 | 579 | for i, job in enumerate(sync_jobs_list): 580 | self.m_list_syncs.InsertItem(i, job.name) 581 | for j, key in enumerate(self.m_list_syncs.data_keys): 582 | self.m_list_syncs.SetItem(i, j, job.__dict__[key]) 583 | 584 | self.m_list_syncs.resizeLastColumn(0) 585 | 586 | def set_row_runnung(self, name, color): 587 | items_num = self.m_list_syncs.GetItemCount() 588 | name_col = self.m_list_syncs.data_keys.index("name") 589 | 590 | for i in range(items_num): 591 | name_in_list = self.m_list_syncs.GetItem(i, name_col).GetText() 592 | if name_in_list == name: 593 | self.m_list_syncs.SetItemTextColour(i, color) 594 | return 595 | 596 | def add_new_job_to_run_list(self, name): 597 | name_col = self.m_list_syncs.data_keys.index("name") 598 | 599 | selected_item = self.m_list_syncs.GetFirstSelected() 600 | 601 | items_num = self.m_list_syncs.GetItemCount() 602 | # TODO: debug wx._core.wxAssertionError exception of line below 603 | try: 604 | name_in_list = self.m_list_syncs.GetItem(selected_item, name_col).GetText() 605 | 606 | job = self.get_job_by_name(name) 607 | 608 | # Add item to list if selected 609 | item_count = len(job.get_log_files()) 610 | if name_in_list == name: 611 | self.m_list_runs.InsertItem(item_count, str(item_count)) 612 | if debug: 613 | print(item_count) 614 | self.m_list_runs.SetItem(item_count, self.m_list_runs.data_keys.index("id"), str(item_count)) 615 | self.m_list_runs.SetItem(item_count, self.m_list_runs.data_keys.index("Time Ran"), "now") 616 | self.m_list_runs.resizeLastColumn(0) 617 | except wx._core.wxAssertionError as e: 618 | print("Got wx._core.wxAssertionError") 619 | print(str(traceback.format_exc())) 620 | print(e) 621 | 622 | def update_start_job(self, name): 623 | self.set_row_runnung(name, "blue") 624 | self.add_new_job_to_run_list(name) 625 | 626 | 627 | def update_end_job(self, name, success): 628 | if success: 629 | self.set_row_runnung(name, "green") 630 | else: 631 | self.set_row_runnung(name, "red") 632 | 633 | def exit(self, event): 634 | wx.Exit() 635 | return 636 | 637 | def show_public_key(self, event): 638 | dialog = self.res.LoadDialog(self, 'show_key_dialog') 639 | dialog.ShowModal() 640 | return 641 | 642 | def show_about(self, event): 643 | dialog = self.res.LoadDialog(self, 'about_dialog') 644 | dialog.ShowModal() 645 | return 646 | 647 | def check_updates(self, event): 648 | latest = get_latest_version() 649 | if latest is None: 650 | # Can't get latest version 651 | wx.MessageBox("Can't get latest version", "Connection error", wx.OK) 652 | elif version.parse(latest) > version.parse(VERSION): 653 | # Newer version available 654 | wants_to_update = wx.MessageBox( 655 | "A new version %s has been found.\n" 656 | "Would you like to download it?" % latest, "New version detected", 657 | wx.YES_NO | wx.YES_DEFAULT, None) == wx.YES 658 | if wants_to_update: 659 | webpage = GITHUB_URL + "/releases/tag/" + latest 660 | webbrowser.open(webpage) 661 | elif version.parse(VERSION) == version.parse(latest): 662 | # Using latest version 663 | wx.MessageBox("Using the latest version of BackupFriend Client", "Current version is latest", wx.OK) 664 | else: 665 | # Error occurred looking for latest version 666 | wx.MessageBox("Error occurred looking for latest version, current is " + VERSION + ". But latest is " + latest, "Error in version parsing", wx.OK) 667 | return 668 | 669 | def show_edit_dialog(self, event): 670 | dialog = self.res.LoadDialog(self, 'edit_job_dialog') 671 | dialog.ShowModal() 672 | return 673 | 674 | def show_create_dialog(self, event): 675 | dialog = self.res.LoadDialog(self, 'job_dialog') 676 | dialog.ShowModal() 677 | return 678 | 679 | def open_settings(self, event): 680 | if debug: 681 | print("open settings") 682 | if get_os() == "windows": 683 | os.system("notepad " + quote(CONFIG_PATH)) 684 | elif get_os() == "osx": 685 | os.system("open " + quote(CONFIG_PATH)) 686 | else: 687 | os.system("xdg-open '" + CONFIG_PATH + "'") 688 | return 689 | 690 | def onClose(self, event): 691 | print("closing") 692 | self.Hide() 693 | # self.Destroy() 694 | # print(self) 695 | 696 | 697 | class TaskBarIcon(wx.adv.TaskBarIcon): 698 | def __init__(self, frame, app): 699 | self.frame = frame 700 | self.app = app 701 | self.frame.SetLayoutDirection(wx.Layout_LeftToRight) 702 | super(TaskBarIcon, self).__init__() 703 | self.set_icon(TRAY_ICON) 704 | self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.on_left_down) 705 | 706 | def CreatePopupMenu(self): 707 | menu = wx.Menu() 708 | # TODO make settings menu 709 | # create_menu_item(menu, 'Settings', self.on_hello) 710 | self.x = create_menu_item(menu, 'Main', self.on_open_main) 711 | menu.AppendSeparator() 712 | create_menu_item(menu, 'Exit', self.on_exit) 713 | return menu 714 | 715 | def set_icon(self, path): 716 | icon = wx.Icon(path) 717 | self.SetIcon(icon, TRAY_TOOLTIP) 718 | 719 | def on_left_down(self, event): 720 | print('Tray icon was left-clicked.') 721 | # TODO: When clicked and main is open, should ask if to minimize 722 | self.on_open_main(None) 723 | 724 | def on_hello(self, event): 725 | if debug: 726 | print('Hello, world!') 727 | if not hasattr(self, 'settings_frame'): 728 | self.settings_frame = SettingsFrame("Settings", self.frame) 729 | else: 730 | if not self.settings_frame: 731 | print("closed") 732 | self.settings_frame = SettingsFrame("Settings", self.frame) 733 | # print(self.settings_frame.Show()) 734 | print(dir(self.settings_frame)) 735 | 736 | def on_open_main(self, event): 737 | if debug: 738 | print('Opening Main') 739 | self.frame.Show() 740 | self.frame.Raise() 741 | self.app.SetTopWindow(self.frame) 742 | 743 | 744 | def on_exit(self, event): 745 | wx.CallAfter(self.Destroy) 746 | self.frame.Close() 747 | self.frame.Destroy() 748 | 749 | 750 | class SyncProcess(wx.Process): 751 | def __init__(self, *args, **kw): 752 | self.terminated = False 753 | wx.Process.__init__(self, *args, **kw) 754 | 755 | def OnTerminate(self, pid, status): 756 | self.terminated = True 757 | 758 | 759 | def expand_user_data(path): 760 | if "__user_data__" in path: 761 | path = path.replace("__user_data__", "") 762 | if path.startswith("\\") or path.startswith("/"): 763 | path = path[1:] 764 | path = os.path.join(DATA_PATH, path) 765 | return path 766 | 767 | @dataclass 768 | class Backup: 769 | name: str 770 | source: str 771 | dest: str 772 | port: str 773 | key: str 774 | server_url: str 775 | server_username: str 776 | every: str 777 | time: str 778 | window: wx.Frame 779 | test_dummy: bool 780 | 781 | def prepare_job(self): 782 | self.process_object = None 783 | self.pid = None 784 | if debug: 785 | print("Starting: " + str(self.name)) 786 | self.log_file = os.path.join(self.get_run_folder(), str(self.get_id())) 787 | return 788 | 789 | def __post_init__(self): 790 | self.process_object = None 791 | self.pid = None 792 | self.key = expand_user_data(self.key) 793 | 794 | if not self.test_dummy and self.every == "daily": 795 | # schedule.every().seconds.do( 796 | # lambda: self.run_backup()) 797 | schedule.every().day.at(self.time).do(lambda: self.run_backup()) 798 | 799 | def get_run_folder(self): 800 | return os.path.join(DATA_PATH, "jobs_data", str(self.name)) 801 | 802 | def get_id(self): 803 | run_folder = self.get_run_folder() 804 | if not ensure_dir(run_folder): 805 | return 0 806 | 807 | log_files = self.get_log_files() 808 | for i, folder in enumerate(log_files): 809 | # print(i, folder) 810 | if str(i) != str(folder): 811 | return str(i) 812 | 813 | return len(log_files) 814 | 815 | def get_log_files(self): 816 | """ Returns the list of log files sorted by id 817 | """ 818 | run_folder = self.get_run_folder() 819 | if not os.path.isdir(run_folder): 820 | return [] 821 | return sorted(os.listdir(run_folder), key=lambda x: float(x)) 822 | 823 | def update_log(self, text): 824 | with open(self.log_file, "ab") as log: 825 | log.write(text) 826 | 827 | def get_log(self, run_name): 828 | log_file = os.path.join(self.get_run_folder(), run_name) 829 | if not os.path.isfile(log_file): 830 | return "Log empty" 831 | with open(log_file, "r") as log: 832 | return_value = log.read() 833 | return return_value 834 | 835 | def get_run_created(self, run_id): 836 | run_path = os.path.join(self.get_run_folder(), run_id) 837 | 838 | return time.ctime(os.path.getctime(run_path)) 839 | 840 | def running(self): 841 | return self.process_object is not None and ( not self.process_object.terminated) 842 | 843 | def test_connection(self): 844 | # TODO: Test if path to ssh command exist beforehand 845 | if not os.path.isdir(self.source): 846 | return "Path does not exist" 847 | 848 | if self.key == "": 849 | return "SSH key can't be empty" 850 | 851 | if not os.path.isfile(self.key): 852 | return "SSH key path does not exist" 853 | 854 | _, ssh_path = self.get_bin_ssh_path() 855 | 856 | hostname_and_user = self.dest.split("::")[0] 857 | hostname = hostname_and_user.split("@")[1] 858 | dest_path = self.dest.split("::")[1] 859 | 860 | command = [ssh_path, hostname_and_user, "-p", str(self.port), "-o", "StrictHostKeyChecking=no", "-i", self.key, "whoami"] 861 | 862 | try: 863 | stdout, stderror, is_timeout = _run_command(command) 864 | if is_timeout: 865 | return "Failed to conenct to server: " + str(hostname) 866 | if stderror != "": 867 | return stderror 868 | except Exception as e: 869 | return "Got exception when running command: " + str(e) 870 | 871 | 872 | # At this point we have a connection that works, the dest folder might be missing 873 | 874 | command = [ssh_path, hostname_and_user, "-p", str(self.port), "-o", "StrictHostKeyChecking=no", "-i", self.key, "mkdir -p " + dest_path] 875 | 876 | try: 877 | stdout, stderror, is_timeout = _run_command(command) 878 | if is_timeout: 879 | return "Failed to conenct to server: " + str(hostname) 880 | if stderror != "": 881 | return "Folder on server does not exist or has no permission: " + dest_path 882 | except Exception as e: 883 | return "Got exception when running command: " + str(e) 884 | 885 | return "Connection succeeded" 886 | 887 | def get_bin_ssh_path(self): 888 | bin_path = config["main"]["bin"] 889 | ssh_path = config["main"]["ssh"] 890 | 891 | if get_os() == "windows": 892 | if debug: 893 | print("windows detected, adjusting binary path in package") 894 | 895 | # rdiff_path = r'"C:\Users\user\Desktop\backupfriend-client\src\rdiff-backup.exe"' 896 | # ssh_path = r'C:\Users\user\Desktop\backupfriend-client\ssh.exe' 897 | ssh_path = ssh_path.replace("__package_path__", resource_path()) 898 | bin_path = bin_path.replace("__package_path__", resource_path()) 899 | 900 | elif get_os() == "osx" or get_os() == "linux": 901 | # Handle in mac first run from app, or first run from python script 902 | if APP_BIN_PATH is not None: 903 | bin_path = bin_path.replace("__app_bin_path__", APP_BIN_PATH) 904 | else: 905 | bin_path = bin_path.replace("__app_bin_path__", "/usr/local/bin") 906 | return bin_path, ssh_path 907 | 908 | def run_backup(self): 909 | pub.sendMessage(START_JOB_MSG, name=self.name) 910 | self.prepare_job() 911 | if debug: 912 | print("hello!!!!!!!!!!!!!!") 913 | config = get_config() 914 | 915 | self.process_object = SyncProcess(self.window) 916 | self.process_object.Redirect() 917 | 918 | bin_path, ssh_path = self.get_bin_ssh_path() 919 | 920 | if get_os() == "windows": 921 | cmd = [bin_path, "-v6", "--remote-schema", 922 | '"' + ssh_path + " -p " + str(self.port) + " -o StrictHostKeyChecking=no -i '" + self.key + "' %s rdiff-backup --server" + '"', "--", '"' + self.source + '"', 923 | self.dest] 924 | command = " ".join(cmd) 925 | 926 | known_hosts_location = os.path.realpath(os.path.join(os.path.dirname(ssh_path), "..", "home", os.getlogin())) 927 | ensure_dir(known_hosts_location) 928 | 929 | else: 930 | cmd = [bin_path, 931 | "-v6", 932 | " --remote-schema 'ssh -p " + str(self.port) + " -o StrictHostKeyChecking=no -i \"" + self.key + "\" %s rdiff-backup --server'", 933 | "--", quote(self.source), quote(self.dest)] 934 | command = " ".join(cmd) 935 | 936 | if debug: 937 | print("running: " + command) 938 | print("running: " + str(command)) 939 | 940 | self.pid = wx.Execute(command, wx.EXEC_ASYNC, callback=self.process_object) 941 | 942 | if debug: 943 | print("pid: " + str(self.pid)) 944 | time.sleep(1) 945 | stream = self.process_object.GetInputStream() 946 | 947 | while stream is not None and stream.CanRead(): 948 | text = stream.read() 949 | self.update_log(text) 950 | wx.LogMessage(text) 951 | 952 | stream_err = self.process_object.GetErrorStream() 953 | 954 | while stream_err is not None and stream_err.CanRead(): 955 | text = stream_err.read() 956 | self.update_log(text) 957 | wx.LogMessage(text) 958 | 959 | print("Finish reading") 960 | return 961 | 962 | 963 | ## def OnIdle(self, evt): 964 | ## if self.sync_jobs is not None: 965 | ## for sync_job in self.sync_jobs: 966 | ## if sync_job.process_object is not None: 967 | ## if sync_job.process_object.terminated: 968 | ## print("terminated") 969 | ## 970 | ## stream = sync_job.process_object.GetInputStream() 971 | ## 972 | ## while stream is not None and stream.CanRead(): 973 | ## text = stream.read() 974 | ## sync_job.update_log(text) 975 | ## 976 | ## print(text.decode()) 977 | ## 978 | ## stream_err = sync_job.process_object.GetErrorStream() 979 | ## 980 | ## while stream_err is not None and stream_err.CanRead(): 981 | ## text = stream_err.read() 982 | ## sync_job.update_log(text) 983 | ## 984 | ## sync_job.process_object = None 985 | ## else: 986 | ## try: 987 | ## stream = sync_job.process_object.GetInputStream() 988 | ## 989 | ## while stream is not None and stream.CanRead(): 990 | ## text = stream.read() 991 | ## sync_job.update_log(text) 992 | ## 993 | ## print(text.decode()) 994 | ## 995 | ## stream_err = sync_job.process_object.GetErrorStream() 996 | ## 997 | ## while stream_err is not None and stream_err.CanRead(): 998 | ## text = stream_err.read() 999 | ## sync_job.update_log(text) 1000 | ## 1001 | ## print(text.decode()) 1002 | ## except RuntimeError as e: 1003 | ## print(e) 1004 | ## # import code; 1005 | ## # code.interact(local=dict(globals(), **locals())) 1006 | ## 1007 | ## # print("Done idle") 1008 | 1009 | 1010 | class App(wx.App): 1011 | 1012 | def OnInit(self): 1013 | locale.setlocale(locale.LC_ALL,'C') 1014 | wx.Log.SetActiveTarget(wx.LogStderr()) 1015 | 1016 | if debug: 1017 | print("Starting App OnInit") 1018 | frame = MainFrame("BackupFriend") 1019 | self.SetTopWindow(frame) 1020 | taskbar = TaskBarIcon(frame, self) 1021 | 1022 | # if not os.path.isfile(os.path.join(DATA_PATH, "id_rsa")): 1023 | # taskbar.on_open_main(None) 1024 | # frame2 = MainFrame(frame, "Main") 1025 | 1026 | return True 1027 | 1028 | 1029 | def main(): 1030 | app = App(False) 1031 | app.MainLoop() 1032 | 1033 | 1034 | if __name__ == '__main__': 1035 | main() 1036 | -------------------------------------------------------------------------------- /src/backupfriend/make_ssh_key.py: -------------------------------------------------------------------------------- 1 | from cryptography.hazmat.primitives import serialization 2 | from cryptography.hazmat.primitives.asymmetric import rsa 3 | from cryptography.hazmat.backends import default_backend 4 | import os 5 | from backupfriend.common import ensure_dir 6 | 7 | 8 | def generate_keys(path): 9 | # generate private/public key pair 10 | key = rsa.generate_private_key(backend=default_backend(), public_exponent=65537, key_size=2048) 11 | 12 | # get public key in OpenSSH format 13 | public_key = key.public_key().public_bytes(serialization.Encoding.OpenSSH, serialization.PublicFormat.OpenSSH) 14 | 15 | # get private key in PEM container format 16 | pem = key.private_bytes(encoding=serialization.Encoding.PEM, 17 | format=serialization.PrivateFormat.TraditionalOpenSSL, 18 | encryption_algorithm=serialization.NoEncryption()) 19 | 20 | # decode to printable strings 21 | private_key_str = pem.decode('utf-8') 22 | public_key_str = public_key.decode('utf-8') 23 | 24 | ensure_dir(path) 25 | 26 | private_key_path = os.path.join(path, "id_rsa") 27 | with open(private_key_path, "w") as w: 28 | w.write(private_key_str) 29 | os.chmod(private_key_path, 0o600) 30 | with open(os.path.join(path, "id_rsa.pub"), "w") as w: 31 | w.write(public_key_str) 32 | 33 | return private_key_str, public_key_str 34 | -------------------------------------------------------------------------------- /src/backupfriend/res/main.xrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Generates SSH keys so you can place them in the rdiff server 13 | 14 | 15 | 16 | Generates SSH keys so you can place them in the rdiff server 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 1000,721 38 | 39 | wxVERTICAL 40 | 41 | 42 | wxALL 43 | 5 44 | 45 | 46 | -1 47 | 48 | 49 | 50 | 51 | wxALL|wxEXPAND 52 | 5 53 | 54 | 55 | 56 | 57 | 58 | 59 | wxEXPAND 60 | 5 61 | 62 | 63 | 64 | 65 | 1 66 | 5 67 | 68 | 0 69 | 70 | 0 71 | 0 72 | 0 73 | 74 | 75 | 76 | 0 77 | 78 | 0 79 | 0 80 | 0 81 | 82 | 83 | 84 | 0 85 | 86 | 0 87 | 0 88 | 0 89 | 90 | 91 | 92 | 0 93 | 94 | 0 95 | 0 96 | 0 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 0 105 | 0 106 | 0 107 | 108 | 109 | 110 | 111 | 112 | 113 | wxEXPAND | wxALL 114 | 5 115 | 116 | 117 | 118 | 119 | 120 | 121 | wxALL|wxEXPAND 122 | 5 123 | 124 | wxHORIZONTAL 125 | 126 | 127 | wxALL|wxEXPAND 128 | 5 129 | 130 | wxVERTICAL 131 | 132 | 133 | 134 | 5 135 | 136 | 137 | -1 138 | 139 | 140 | 141 | 142 | wxALL|wxEXPAND 143 | 5 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | wxEXPAND 153 | 5 154 | 155 | wxVERTICAL 156 | 157 | 158 | 159 | 5 160 | 161 | 162 | -1 163 | 164 | 165 | 166 | 167 | wxEXPAND 168 | 5 169 | 170 | wxVERTICAL 171 | 172 | 173 | wxALL|wxEXPAND|wxSHAPED 174 | 5 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | First Time Setup 191 | 1 192 | 193 | 194 | wxVERTICAL 195 | 196 | 197 | wxALL 198 | 5 199 | 200 | 201 | 250 202 | 203 | 204 | 205 | 206 | 207 | 208 | wxVERTICAL 209 | 210 | 211 | wxALL|wxEXPAND 212 | 5 213 | 214 | 215 | -1 216 | 217 | 218 | 219 | 220 | wxALL|wxEXPAND 221 | 5 222 | 223 | 224 | 0 225 | 0 226 | 0 227 | 228 | 229 | 230 | 231 | 232 | wxALL 233 | 5 234 | 235 | 236 | -1 237 | 238 | 239 | 240 | 241 | 242 | 243 | wxVERTICAL 244 | 245 | 246 | wxALL|wxEXPAND 247 | 5 248 | 249 | 250 | -1 251 | 252 | 253 | 254 | 255 | wxALL|wxEXPAND|wxSHAPED 256 | 5 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | wxALL 265 | 5 266 | 267 | 268 | 0 269 | 0 270 | 0 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | Public Key 280 | 1 281 | 282 | wxVERTICAL 283 | 284 | 285 | wxALL 286 | 5 287 | 288 | 289 | -1 290 | 291 | 292 | 293 | 294 | wxALL|wxEXPAND 295 | 5 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | wxALL 304 | 5 305 | 306 | 307 | 0 308 | 0 309 | 0 310 | 311 | 312 | 313 | 314 | 315 | wxALL 316 | 5 317 | 318 | 319 | 0 320 | 0 321 | 0 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | Create New Backup Job 330 | 1 331 | 332 | wxVERTICAL 333 | 334 | 335 | wxEXPAND 336 | 5 337 | 338 | 0 339 | 2 340 | 0 341 | 0 342 | 343 | 344 | wxALL 345 | 5 346 | 347 | 348 | -1 349 | 350 | 351 | 352 | 353 | wxALL|wxEXPAND 354 | 5 355 | 356 | 357 | 358 | 359 | 360 | 361 | wxALL 362 | 5 363 | 364 | 365 | -1 366 | 367 | 368 | 369 | 370 | wxALL|wxEXPAND 371 | 5 372 | 373 | 374 | Select a folder 375 | 376 | 377 | 378 | 379 | 380 | wxALL 381 | 5 382 | 383 | 384 | -1 385 | 386 | 387 | 388 | 389 | wxALL|wxEXPAND 390 | 5 391 | 392 | Location for backing up your files 393 | user@backupfriend.local::/backup 394 | 395 | 396 | 397 | 398 | wxALL 399 | 5 400 | 401 | 402 | -1 403 | 404 | 405 | 406 | 407 | wxALL 408 | 5 409 | 410 | 411 | 8022 412 | 0 413 | 65535 414 | 415 | 416 | 417 | 418 | wxALL 419 | 5 420 | 421 | 422 | -1 423 | 424 | 425 | 426 | 427 | wxALL|wxEXPAND 428 | 5 429 | 430 | 431 | Select the id__rsa key 432 | *.* 433 | 434 | 435 | 436 | 437 | 438 | wxALL 439 | 5 440 | 441 | 442 | -1 443 | 444 | 445 | 446 | 447 | wxALL|wxEXPAND 448 | 5 449 | 450 | http://backupfriend.local 451 | 452 | 453 | 454 | 455 | wxALL 456 | 5 457 | 458 | 459 | -1 460 | 461 | 462 | 463 | 464 | wxALL 465 | 5 466 | 467 | admin 468 | 469 | 470 | 471 | 472 | wxALL 473 | 5 474 | 475 | 476 | -1 477 | 478 | 479 | 480 | 481 | wxALL|wxEXPAND 482 | 5 483 | 484 | 485 | -1 486 | 487 | 488 | 489 | 490 | wxALL 491 | 5 492 | 493 | 494 | -1 495 | 496 | 497 | 498 | 499 | wxALL 500 | 5 501 | 502 | 503 | 504 | 505 | 506 | 507 | wxALL|wxEXPAND 508 | 5 509 | 510 | 511 | -1 512 | 513 | 514 | 515 | 516 | wxEXPAND 517 | 5 518 | 0,0 519 | 520 | 521 | 522 | wxEXPAND 523 | 5 524 | 0,0 525 | 526 | 527 | 528 | wxALIGN_RIGHT 529 | 5 530 | 531 | wxHORIZONTAL 532 | 533 | 534 | wxALL 535 | 5 536 | 537 | 538 | 0 539 | 0 540 | 0 541 | 542 | 543 | 544 | 545 | 546 | wxALL 547 | 5 548 | 549 | 550 | 0 551 | 0 552 | 0 553 | 554 | 555 | 556 | 557 | 558 | wxALL 559 | 5 560 | 561 | 562 | 0 563 | 0 564 | 0 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | Edit a Backup Job 577 | 1 578 | 579 | wxVERTICAL 580 | 581 | 582 | wxEXPAND 583 | 5 584 | 585 | 0 586 | 2 587 | 0 588 | 0 589 | 590 | 591 | wxALL 592 | 5 593 | 594 | 595 | -1 596 | 597 | 598 | 599 | 600 | wxALL|wxEXPAND 601 | 5 602 | 603 | 604 | 605 | 606 | 607 | 608 | wxALL 609 | 5 610 | 611 | 612 | -1 613 | 614 | 615 | 616 | 617 | wxALL|wxEXPAND 618 | 5 619 | 620 | 621 | Select a folder 622 | 623 | 624 | 625 | 626 | 627 | wxALL 628 | 5 629 | 630 | 631 | -1 632 | 633 | 634 | 635 | 636 | wxALL|wxEXPAND 637 | 5 638 | 639 | Location for backing up your files 640 | user@backupfriend.local::/backup 641 | 642 | 643 | 644 | 645 | wxALL 646 | 5 647 | 648 | 649 | -1 650 | 651 | 652 | 653 | 654 | wxALL 655 | 5 656 | 657 | 658 | 8022 659 | 0 660 | 65535 661 | 662 | 663 | 664 | 665 | wxALL 666 | 5 667 | 668 | 669 | -1 670 | 671 | 672 | 673 | 674 | wxALL|wxEXPAND 675 | 5 676 | 677 | 678 | Select the id__rsa key 679 | *.* 680 | 681 | 682 | 683 | 684 | 685 | wxALL 686 | 5 687 | 688 | 689 | -1 690 | 691 | 692 | 693 | 694 | wxALL|wxEXPAND 695 | 5 696 | 697 | http://backupfriend.local 698 | 699 | 700 | 701 | 702 | wxALL 703 | 5 704 | 705 | 706 | -1 707 | 708 | 709 | 710 | 711 | wxALL 712 | 5 713 | 714 | admin 715 | 716 | 717 | 718 | 719 | wxALL 720 | 5 721 | 722 | 723 | -1 724 | 725 | 726 | 727 | 728 | wxALL|wxEXPAND 729 | 5 730 | 731 | 732 | -1 733 | 734 | 735 | 736 | 737 | wxALL 738 | 5 739 | 740 | 741 | -1 742 | 743 | 744 | 745 | 746 | wxALL 747 | 5 748 | 749 | 750 | 751 | 752 | 753 | 754 | wxALL|wxEXPAND 755 | 5 756 | 757 | 758 | -1 759 | 760 | 761 | 762 | 763 | wxEXPAND 764 | 5 765 | 0,0 766 | 767 | 768 | 769 | wxEXPAND 770 | 5 771 | 0,0 772 | 773 | 774 | 775 | wxALIGN_RIGHT 776 | 5 777 | 778 | wxHORIZONTAL 779 | 780 | 781 | wxALL 782 | 5 783 | 784 | 785 | 0 786 | 0 787 | 0 788 | 789 | 790 | 791 | 792 | 793 | wxALL 794 | 5 795 | 796 | 797 | 0 798 | 0 799 | 0 800 | 801 | 802 | 803 | 804 | 805 | wxALL 806 | 5 807 | 808 | 809 | 0 810 | 0 811 | 0 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 800,800 824 | About Backupfriend Client 825 | 1 826 | 827 | 700,900 828 | wxVERTICAL 829 | 830 | 831 | wxALIGN_CENTER|wxALL 832 | 5 833 | 834 | 835 | 836 | 837 | 838 | 839 | wxALIGN_CENTER|wxALL 840 | 5 841 | 842 | 843 | 16 844 | swiss 845 | 846 | bold 847 | 0 848 | Sans 849 | 850 | 851 | -1 852 | 853 | 854 | 855 | 856 | 857 | 5 858 | 859 | wxHORIZONTAL 860 | 861 | 862 | wxALL 863 | 5 864 | 865 | 866 | -1 867 | 868 | 869 | 870 | 871 | wxALL 872 | 5 873 | 874 | 875 | -1 876 | 877 | 878 | 879 | 880 | 881 | 882 | wxALL 883 | 5 884 | 885 | 886 | 600 887 | 888 | 889 | 890 | 891 | wxALL 892 | 5 893 | 894 | 895 | 600 896 | 897 | 898 | 899 | 900 | wxALIGN_CENTER|wxALL 901 | 5 902 | 903 | 904 | https://github.com/guysoft/backupfriend-client 905 | 906 | 907 | 908 | 909 | 910 | wxALIGN_RIGHT|wxALL 911 | 5 912 | 913 | 914 | 0 915 | 0 916 | 0 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 216,186 925 | 926 | 1 927 | 928 | wxVERTICAL 929 | 930 | 931 | wxALIGN_CENTER|wxEXPAND 932 | 5 933 | 934 | 935 | -1 936 | 937 | 938 | 939 | 940 | wxALIGN_BOTTOM|wxALIGN_CENTER 941 | 5 942 | 943 | wxHORIZONTAL 944 | 945 | 946 | wxALL 947 | 5 948 | 949 | 950 | 0 951 | 0 952 | 0 953 | 954 | 955 | 956 | 957 | 958 | wxALL 959 | 5 960 | 961 | 962 | 0 963 | 0 964 | 0 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | -------------------------------------------------------------------------------- /src/backupfriend/sub.py: -------------------------------------------------------------------------------- 1 | import wx 2 | import os.path 3 | from wx.adv import Wizard 4 | from wx.lib.mixins import listctrl 5 | from wx import xrc 6 | from backupfriend.make_ssh_key import generate_keys 7 | from backupfriend.common import get_data_path 8 | from abc import ABC, abstractmethod 9 | from backupfriend.main import Backup, TRAY_ICON 10 | from backupfriend import __version__ as VERSION 11 | 12 | DATA_PATH = get_data_path() 13 | 14 | 15 | class ResizedList(wx.ListCtrl, listctrl.ListCtrlAutoWidthMixin): 16 | def __init__(self, pos=wx.DefaultPosition, 17 | size=wx.DefaultSize, style=0): 18 | wx.ListCtrl.__init__(self) 19 | listctrl.ListCtrlAutoWidthMixin.__init__(self) 20 | # self.setResizeColumn(0) 21 | 22 | 23 | class ResizedSecondList(wx.ListCtrl, listctrl.ListCtrlAutoWidthMixin): 24 | def __init__(self, pos=wx.DefaultPosition, 25 | size=wx.DefaultSize, style=0): 26 | wx.ListCtrl.__init__(self) 27 | listctrl.ListCtrlAutoWidthMixin.__init__(self) 28 | self.setResizeColumn(2) 29 | 30 | 31 | class FirstRunWizard(Wizard): 32 | def __init__(self, *args, **kw): 33 | Wizard.__init__(self, *args 34 | , **kw) 35 | self.m_wiz_gnerate_keys = xrc.XRCCTRL(self, 'm_wiz_gnerate_keys') 36 | self.Bind(wx.EVT_BUTTON, self.generate_keys, id=xrc.XRCID('m_generate_keys')) 37 | self.Bind(wx.EVT_BUTTON, self.select_all, id=xrc.XRCID('m_select_all')) 38 | self.m_public_key = xrc.XRCCTRL(self, 'm_public_key') 39 | 40 | def select_all(self, event): 41 | page = self.GetCurrentPage() 42 | m_public_key = xrc.XRCCTRL(page, 'm_public_key') 43 | m_public_key.SetSelection(-1, -1) 44 | if wx.TheClipboard.Open(): 45 | wx.TheClipboard.SetData(wx.TextDataObject(m_public_key.GetValue())) 46 | wx.TheClipboard.Close() 47 | return 48 | 49 | def generate_keys(self, event): 50 | private_key_str, public_key_str = generate_keys(DATA_PATH) 51 | # self.m_public_key.SetValue(public_key_str) 52 | page = self.GetCurrentPage() 53 | m_result = xrc.XRCCTRL(page, 'm_result') 54 | m_generate_keys = xrc.XRCCTRL(page, 'm_generate_keys') 55 | 56 | m_result.SetLabel("Generated keys") 57 | m_generate_keys.Disable() 58 | next_page = page.GetNext() 59 | m_public_key = xrc.XRCCTRL(next_page, 'm_public_key') 60 | m_public_key.SetValue(public_key_str) 61 | return 62 | 63 | 64 | class ShowPublicKeyDialog(wx.Dialog): 65 | def __init__(self, *args, **kw): 66 | wx.Dialog.__init__(self, *args, **kw) 67 | self.Bind(wx.EVT_BUTTON, self.select_all, id=xrc.XRCID('m_select_all')) 68 | self.Bind(wx.EVT_BUTTON, self.close, id=xrc.XRCID('m_close')) 69 | 70 | def close(self, event): 71 | self.Close() 72 | 73 | def select_all(self, event): 74 | m_public_key = xrc.XRCCTRL(self, 'm_public_key') 75 | m_public_key.SetSelection(-1, -1) 76 | if wx.TheClipboard.Open(): 77 | wx.TheClipboard.SetData(wx.TextDataObject(m_public_key.GetValue())) 78 | wx.TheClipboard.Close() 79 | return 80 | 81 | def ShowModal(self, *args, **kw): 82 | m_public_key = xrc.XRCCTRL(self, 'm_public_key') 83 | 84 | public_key_path = os.path.join(DATA_PATH, "id_rsa.pub") 85 | if os.path.isfile(public_key_path): 86 | with open(public_key_path) as f: 87 | public_key_str = f.read() 88 | m_public_key.SetValue(public_key_str) 89 | wx.Dialog.ShowModal(self, *args, **kw) 90 | 91 | 92 | class AbstractJobDialog(wx.Dialog): 93 | def __init__(self, *args, **kw): 94 | wx.Dialog.__init__(self, *args, **kw) 95 | self.Bind(wx.EVT_BUTTON, self.close, id=xrc.XRCID('m_cancel')) 96 | self.Bind(wx.EVT_BUTTON, self.save, id=xrc.XRCID('m_save')) 97 | self.Bind(wx.EVT_BUTTON, self.test, id=xrc.XRCID('m_test')) 98 | 99 | return 100 | 101 | 102 | def close(self, event): 103 | self.Close() 104 | 105 | def test(self, event): 106 | """ Test button for connection """ 107 | m_info = xrc.XRCCTRL(self, 'm_info') 108 | m_info.SetLabel("Testing connection") 109 | 110 | backup_dict = self.gather_all_fields() 111 | 112 | test_backup = Backup(**backup_dict, window=self, test_dummy=True) 113 | result = test_backup.test_connection() 114 | m_info.SetLabel(result) 115 | 116 | print(result) 117 | return 118 | 119 | def gather_all_fields(self): 120 | return { 121 | "name": xrc.XRCCTRL(self, 'm_name').GetValue(), 122 | "source": xrc.XRCCTRL(self, 'm_source').GetPath(), 123 | "dest": xrc.XRCCTRL(self, 'm_dest').GetValue(), 124 | "port": xrc.XRCCTRL(self, 'm_port').GetValue(), 125 | "server_url": xrc.XRCCTRL(self, 'm_server_url').GetValue(), 126 | "server_username": xrc.XRCCTRL(self, 'm_server_username').GetValue(), 127 | "key": xrc.XRCCTRL(self, 'm_key_picker').GetPath(), 128 | "every": "daily", 129 | "time": self._time2str(xrc.XRCCTRL(self, 'm_time').GetTime()) 130 | } 131 | 132 | def save(self, event): 133 | backup_dict = self.gather_all_fields() 134 | 135 | try: 136 | if backup_dict["key"] == "": 137 | raise ValueError("SSH key can't be empty") 138 | elif not os.path.isfile(backup_dict["key"]): 139 | raise ValueError("SSH key path does not exist") 140 | 141 | self.updateFunction(backup_dict) 142 | self.Close() 143 | except ValueError as e: 144 | wx.MessageBox(str(e), 'Error', wx.OK | wx.ICON_EXCLAMATION) 145 | 146 | def _time2str(self, time): 147 | time_str = map(str, time[:2]) 148 | time_str = map(lambda st: st if len(st) >1 else "0" + st, time_str) 149 | time_str = ':'.join(time_str) 150 | return time_str 151 | 152 | def updateFunction(self, backup_dict): 153 | pass 154 | 155 | 156 | class AddJobDialog(AbstractJobDialog): 157 | def ShowModal(self, *args, **kw): 158 | m_key = xrc.XRCCTRL(self, 'm_key_picker') 159 | key_path = os.path.join(DATA_PATH, "id_rsa") 160 | # m_key.SetInitialDirectory(os.path.dirname(key_path)) 161 | m_key.SetPath(key_path) 162 | print(m_key.GetPath()) 163 | m_key.Refresh() 164 | return wx.Dialog.ShowModal(self, *args, **kw) 165 | 166 | def updateFunction(self, backup_dict): 167 | self.GetParent().add_backups([backup_dict]) 168 | 169 | 170 | class EditJobDialog(AbstractJobDialog): 171 | def ShowModal(self, *args, **kw): 172 | self.job_name = self.GetParent().current_job 173 | self.backup_to_update = self.GetParent().get_backup_by_name( 174 | self.job_name) 175 | 176 | xrc.XRCCTRL(self, 'm_name').SetValue(self.backup_to_update.name) 177 | xrc.XRCCTRL(self, 'm_source').SetPath(self.backup_to_update.source) 178 | xrc.XRCCTRL(self, 'm_dest').SetValue(self.backup_to_update.dest) 179 | xrc.XRCCTRL(self, 'm_port').SetValue(self.backup_to_update.port) 180 | xrc.XRCCTRL(self, 'm_key_picker').SetPath(self.backup_to_update.key) 181 | xrc.XRCCTRL(self, 'm_server_url').SetValue(self.backup_to_update.server_url) 182 | xrc.XRCCTRL(self, 'm_server_username').SetValue(self.backup_to_update.server_username) 183 | 184 | m_time = xrc.XRCCTRL(self, 'm_time') 185 | time_elems = self.backup_to_update.time.split(':') 186 | time_elems = map(int, time_elems) 187 | m_time.SetTime(*time_elems, 0) 188 | 189 | return wx.Dialog.ShowModal(self, *args, **kw) 190 | 191 | def updateFunction(self, backup_dict): 192 | self.GetParent().update_backup(self.job_name, backup_dict) 193 | 194 | 195 | class DeleteJobDialog(wx.Dialog): 196 | def __init__(self, *args, **kw): 197 | wx.Dialog.__init__(self, *args, **kw) 198 | self.Bind(wx.EVT_BUTTON, self._close, id=xrc.XRCID('m_delete_btn_no')) 199 | self.Bind(wx.EVT_BUTTON, self._delete_job, id=xrc.XRCID('m_delete_btn_yes')) 200 | 201 | def ShowModal(self, *args, **kw): 202 | self.job_name = kw.pop('job_name') 203 | xrc.XRCCTRL(self, "m_static_text_delete").SetLabel( 204 | f"Are you sure you want to delete '{self.job_name}'?") 205 | 206 | return wx.Dialog.ShowModal(self, *args, **kw) 207 | 208 | def _delete_job(self, event): 209 | self.GetParent().delete_backup(self.job_name) 210 | self.Close() 211 | 212 | def _close(self, event): 213 | self.Close() 214 | 215 | 216 | class AboutDialog(wx.Dialog): 217 | def __init__(self, *args, **kw): 218 | wx.Dialog.__init__(self, *args, **kw) 219 | 220 | def ShowModal(self, *args, **kw): 221 | xrc.XRCCTRL(self, "m_version").SetLabel(VERSION) 222 | xrc.XRCCTRL(self, "m_logo").SetBitmap(wx.Bitmap(TRAY_ICON)) 223 | self.Bind(wx.EVT_BUTTON, self._close, id=xrc.XRCID('m_close')) 224 | 225 | return wx.Dialog.ShowModal(self, *args, **kw) 226 | 227 | def _delete_job(self, event): 228 | self.GetParent().delete_backup(self.job_name) 229 | self.Close() 230 | 231 | def _close(self, event): 232 | self.Close() 233 | 234 | -------------------------------------------------------------------------------- /src/backupfriendclient.py: -------------------------------------------------------------------------------- 1 | def run(): 2 | import wx 3 | from backupfriend.main import main 4 | # Needed so pyinstaller will detect it needs this module 5 | import backupfriend.sub 6 | 7 | print(backupfriend) 8 | 9 | main() 10 | return 11 | 12 | if __name__ == "__main__": 13 | run() 14 | -------------------------------------------------------------------------------- /src/build-scripts/get_ssh_bin: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir ssh_bin 3 | pushd ssh_bin 4 | wget https://www.mls-software.com/files/setupssh-8.4p1-1.exe 5 | 7z e -aou setupssh-8.4p1-1.exe 6 | 7 | # Get only 64 bit 8 | rm $(file * | grep 80386 | awk '{print substr($1, 1, length($1)-1)}' | xargs) 9 | 10 | for i in *; do 11 | FROM=$i 12 | TO=$(echo $i | sed 's/_1//g') 13 | if [ "$FROM" != "$TO" ]; then 14 | mv "$FROM" "$TO" 15 | fi 16 | done 17 | popd 18 | 19 | # objdump --private-headers ssh.exe | grep dll | awk '{ print $3 }' 20 | -------------------------------------------------------------------------------- /src/build.txt: -------------------------------------------------------------------------------- 1 | pip install wget 2 | python -m wget https://download3.portableapps.com/portableapps/Notepad++Portable/NotepadPlusPlusPortable_7.8.5_Rev_3.paf.exe?20190321 3 | python -m wget https://github.com/rdiff-backup/rdiff-backup/releases/download/v2.0.5/rdiff-backup-2.0.5.win32exe.zip 4 | unzip rdiff-backup-2.0.5.win32exe.zip 5 | pyinstaller --add-data="backupfriend\config;backupfriend\config" --add-data="backupfriend\images;backupfriend\images" --add-data="backupfriend\res;backupfriend\res" --noconsole --add-binary="rdiff-backup.exe;bin" backupfriend-client.py 6 | --------------------------------------------------------------------------------