Compare commits
3 commits
f774219c71
...
2c00a11676
Author | SHA1 | Date | |
---|---|---|---|
2c00a11676 | |||
5d367fa1a8 | |||
1dfe37a970 |
3 changed files with 123 additions and 17 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,6 +1,10 @@
|
||||||
# Changelog Backuppy
|
# Changelog Backuppy
|
||||||
|
|
||||||
## [1.02.000] - 2021-05-05
|
## [0.6] - 2021-05-06
|
||||||
|
### Added
|
||||||
|
- Write alias to Backuppy.sh into .bashrc/.zshrc only if not already existing
|
||||||
|
|
||||||
|
## [0.5.2] - 2021-05-05
|
||||||
### Added
|
### Added
|
||||||
- Now fully functional as the shell version
|
- Now fully functional as the shell version
|
||||||
|
|
||||||
|
@ -11,11 +15,11 @@
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed problem with the Bash/ZSH config
|
- Fixed problem with the Bash/ZSH config
|
||||||
|
|
||||||
## [1.01.001] - 2021-05-04
|
## [0.5.1] - 2021-05-04
|
||||||
### Changed
|
### Changed
|
||||||
- Use E-MAIL constant
|
- Use E-MAIL constant
|
||||||
|
|
||||||
## [1.01.000] - 2021-05-04
|
## [0.5] - 2021-05-04
|
||||||
### Added
|
### Added
|
||||||
- Graphical installer based on Python3 with PySide2 GUI framework (Qt-bindings for Python)
|
- Graphical installer based on Python3 with PySide2 GUI framework (Qt-bindings for Python)
|
||||||
- Changelog.MD
|
- Changelog.MD
|
||||||
|
|
35
install.py
35
install.py
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
project: Backuppy
|
project: Backuppy
|
||||||
version: 1.02.000
|
version: 0.6
|
||||||
file: install.py
|
file: install.py
|
||||||
summary: main entry python file
|
summary: main entry python file
|
||||||
"""
|
"""
|
||||||
|
@ -10,16 +10,14 @@ summary: main entry python file
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
from PySide2 import QtCore
|
from PySide2 import QtWidgets
|
||||||
from PySide2 import QtGui
|
|
||||||
from PySide2 import QtCore, QtWidgets
|
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from languages import english
|
from languages import english
|
||||||
from languages import german
|
from languages import german
|
||||||
|
|
||||||
# local globals
|
# local globals
|
||||||
VERSION: str = "1.02.000"
|
VERSION: str = "0.6"
|
||||||
EMAIL: str = "fotocoder@joschu.ch"
|
EMAIL: str = "fotocoder@joschu.ch"
|
||||||
TARGET_SCRIPT: str = "Backuppy.sh"
|
TARGET_SCRIPT: str = "Backuppy.sh"
|
||||||
EXCLUDE_FILE: str = "exclude.txt"
|
EXCLUDE_FILE: str = "exclude.txt"
|
||||||
|
@ -44,7 +42,7 @@ def get_lang_text(search_str: str):
|
||||||
|
|
||||||
def trace(message_txt: str):
|
def trace(message_txt: str):
|
||||||
""" Print a formatted message to std out. """
|
""" Print a formatted message to std out. """
|
||||||
print(f"[ OK ]", message_txt)
|
print("[ OK ]" + message_txt)
|
||||||
|
|
||||||
class BackuppyWizard(QtWidgets.QWizard):
|
class BackuppyWizard(QtWidgets.QWizard):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
@ -295,20 +293,29 @@ def create_shell_script(command_str: str):
|
||||||
user_home = os.environ.get("HOME")
|
user_home = os.environ.get("HOME")
|
||||||
|
|
||||||
## STEP 1: update shell config scripts with alias for backuppy
|
## STEP 1: update shell config scripts with alias for backuppy
|
||||||
# .zshrc case1 and case2
|
# Check for installed ZSH
|
||||||
if current_shell in ("/usr/bin/zsh", "/bin/zsh"):
|
if current_shell.upper().find("ZSH") > 0:
|
||||||
# Appending to bash config file
|
|
||||||
rc_filepath = os.path.join(user_home, ".zshrc")
|
rc_filepath = os.path.join(user_home, ".zshrc")
|
||||||
|
|
||||||
# .bashrc case1 and case2
|
# Check for installed BASH
|
||||||
elif current_shell in ("/usr/bin/bash", "/bin/bash"):
|
if current_shell.upper().find("BASH") > 0:
|
||||||
# Appending to zsh config file
|
|
||||||
rc_filepath = os.path.join(user_home, ".bashrc")
|
rc_filepath = os.path.join(user_home, ".bashrc")
|
||||||
|
|
||||||
|
# Append our alias if not already existing
|
||||||
if os.path.isfile(rc_filepath):
|
if os.path.isfile(rc_filepath):
|
||||||
with open(rc_filepath, 'a') as file1:
|
fileRc = open(rc_filepath, "r") # open file in read mode
|
||||||
|
|
||||||
|
backuppy_entry_exists = False
|
||||||
|
for line in fileRc:
|
||||||
|
if "alias backuppy=" in line:
|
||||||
|
backuppy_entry_exists = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not backuppy_entry_exists:
|
||||||
trace(f"Writing {ALIAS_STR} to config file '{rc_filepath}'.")
|
trace(f"Writing {ALIAS_STR} to config file '{rc_filepath}'.")
|
||||||
file1.write("\n# Following line was created by Backuppy\n" + ALIAS_STR + "\n")
|
fileRc = open(rc_filepath, "a") # open file in append mode
|
||||||
|
fileRc.write("\n# Following line was created by Backuppy\n" + ALIAS_STR + "\n")
|
||||||
|
fileRc.close()
|
||||||
|
|
||||||
## STEP 2: Create the exclude script if desired
|
## STEP 2: Create the exclude script if desired
|
||||||
if EXCLUDE:
|
if EXCLUDE:
|
||||||
|
|
95
install_cli.py
Normal file
95
install_cli.py
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
MYDIR = os.getcwd()
|
||||||
|
SHELL = os.environ.get("SHELL")
|
||||||
|
HOME = os.environ.get("HOME")
|
||||||
|
|
||||||
|
# Intro
|
||||||
|
# language
|
||||||
|
|
||||||
|
language = input("Hello, first of all, which language do you prefer: German [DE] or English [EN]?\n> ")
|
||||||
|
if language.upper() == "DE":
|
||||||
|
from languages.german import *
|
||||||
|
print("Perfekt, nun ist das deutsche Sprachpaket aktiviert. Willkommen!\n")
|
||||||
|
else:
|
||||||
|
from languages.english import *
|
||||||
|
print("Perfect, the English language package is now activated. Welcome!.\n")
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
print("\n" + intromsg1 + "\n")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
print("\n" + intromsg2 + "\n")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# Installer
|
||||||
|
|
||||||
|
# creates the file 'Backuppy.sh'
|
||||||
|
fBackuppy = open("Backuppy.sh", "w")
|
||||||
|
fBackuppy.write("#!/bin/bash")
|
||||||
|
os.chmod("Backuppy.sh", 0o777) # make file executable
|
||||||
|
|
||||||
|
# which Rsync options are available and which one you want to use
|
||||||
|
print(rsyncopt + "\n")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# asks if you want to exclude files/directories from backup and creates an exclude file in case of Yes
|
||||||
|
exclude = input(excludefile1 + "\n> ")
|
||||||
|
if exclude.upper() in ("J", "Y"):
|
||||||
|
print(excludefile2 + "\n")
|
||||||
|
fExclude = open("exclude.txt", "w")
|
||||||
|
fExclude.close()
|
||||||
|
else:
|
||||||
|
print(excludefile3 + "\n")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# Asks for the source directory which should be saved
|
||||||
|
print(srcdir1)
|
||||||
|
time.sleep(1)
|
||||||
|
sourcedir = input(srcdir2 + "\n> ")
|
||||||
|
|
||||||
|
print(f"{srcdir3_1} {sourcedir} {srcdir3_2}")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# asks for the destination directory in which the backup should be saved
|
||||||
|
targetdir = input(targetdir1 + "\n> ")
|
||||||
|
print(f"{targetdir2_1} {targetdir} {targetdir2_2}")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# alias entry in .bashrc or .zshrc
|
||||||
|
print(SHELL)
|
||||||
|
|
||||||
|
# .zshrc case1 and case2
|
||||||
|
if SHELL.upper().find("ZSH") >0:
|
||||||
|
# Appending to bash config file
|
||||||
|
fRc = open(os.path.join(HOME, ".zshrc"), "a") # append mode
|
||||||
|
fRc.write("\n" + f"alias backuppy='sudo {MYDIR}/Backuppy.sh'" + "\n")
|
||||||
|
fRc.close()
|
||||||
|
|
||||||
|
# .bashrc case1 and case2
|
||||||
|
elif SHELL.upper().find("BASH") >0:
|
||||||
|
# Appending to zsh config file
|
||||||
|
fRc = open(os.path.join(HOME, ".bashrc"), "a") # append mode
|
||||||
|
fRc.write("\n" + f"alias backuppy='sudo {MYDIR}/Backuppy.sh'" + "\n")
|
||||||
|
fRc.close()
|
||||||
|
|
||||||
|
# collects all the information needed to execute the rsync command and creates it.
|
||||||
|
print(collect + "\n")
|
||||||
|
time.sleep(1)
|
||||||
|
print(f"rsync -aqp --exclude-from={MYDIR}/exclude.txt {sourcedir} {targetdir}\n")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# enter the rsync command in Backuppy.sh
|
||||||
|
fBackuppy.write("\n" + f"rsync -aqp --exclude-from={MYDIR}/exclude.txt {sourcedir} {targetdir}" + "\n")
|
||||||
|
fBackuppy.close()
|
||||||
|
|
||||||
|
# Outro
|
||||||
|
print(outro1)
|
||||||
|
time.sleep(2)
|
||||||
|
print(outro2 + " fotocoder@joschu.ch")
|
Loading…
Reference in a new issue