Compare commits

..

No commits in common. "2c00a116762c8f2fe37889b26276a85ac033eb89" and "f774219c71610ca4732818117ad9ff7f87a57b16" have entirely different histories.

3 changed files with 17 additions and 123 deletions

View file

@ -1,10 +1,6 @@
# Changelog Backuppy
## [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
## [1.02.000] - 2021-05-05
### Added
- Now fully functional as the shell version
@ -15,11 +11,11 @@
### Fixed
- Fixed problem with the Bash/ZSH config
## [0.5.1] - 2021-05-04
## [1.01.001] - 2021-05-04
### Changed
- Use E-MAIL constant
## [0.5] - 2021-05-04
## [1.01.000] - 2021-05-04
### Added
- Graphical installer based on Python3 with PySide2 GUI framework (Qt-bindings for Python)
- Changelog.MD

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""
project: Backuppy
version: 0.6
version: 1.02.000
file: install.py
summary: main entry python file
"""
@ -10,14 +10,16 @@ summary: main entry python file
import os
# Third party imports
from PySide2 import QtWidgets
from PySide2 import QtCore
from PySide2 import QtGui
from PySide2 import QtCore, QtWidgets
# local imports
from languages import english
from languages import german
# local globals
VERSION: str = "0.6"
VERSION: str = "1.02.000"
EMAIL: str = "fotocoder@joschu.ch"
TARGET_SCRIPT: str = "Backuppy.sh"
EXCLUDE_FILE: str = "exclude.txt"
@ -42,7 +44,7 @@ def get_lang_text(search_str: str):
def trace(message_txt: str):
""" Print a formatted message to std out. """
print("[ OK ]" + message_txt)
print(f"[ OK ]", message_txt)
class BackuppyWizard(QtWidgets.QWizard):
def __init__(self, parent=None):
@ -293,29 +295,20 @@ def create_shell_script(command_str: str):
user_home = os.environ.get("HOME")
## STEP 1: update shell config scripts with alias for backuppy
# Check for installed ZSH
if current_shell.upper().find("ZSH") > 0:
# .zshrc case1 and case2
if current_shell in ("/usr/bin/zsh", "/bin/zsh"):
# Appending to bash config file
rc_filepath = os.path.join(user_home, ".zshrc")
# Check for installed BASH
if current_shell.upper().find("BASH") > 0:
# .bashrc case1 and case2
elif current_shell in ("/usr/bin/bash", "/bin/bash"):
# Appending to zsh config file
rc_filepath = os.path.join(user_home, ".bashrc")
# Append our alias if not already existing
if os.path.isfile(rc_filepath):
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:
with open(rc_filepath, 'a') as file1:
trace(f"Writing {ALIAS_STR} to config file '{rc_filepath}'.")
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()
file1.write("\n# Following line was created by Backuppy\n" + ALIAS_STR + "\n")
## STEP 2: Create the exclude script if desired
if EXCLUDE:

View file

@ -1,95 +0,0 @@
#!/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")