From dc2a434fe3841efe5b3cc6b4f1f7f085541c0521 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Tue, 8 Mar 2022 14:58:04 +0100 Subject: [PATCH 01/54] Add part for local cloud files --- cloud-backup-data.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cloud-backup-data.txt b/cloud-backup-data.txt index 4da9a4e..6b82e46 100644 --- a/cloud-backup-data.txt +++ b/cloud-backup-data.txt @@ -22,3 +22,6 @@ YOURURL/remote.php/dav/calendars/USERNAME/ # List your calendar names with commas and no spaces. # Maybe you have to check the individual urls for the correct deposited names (e.g. "holidays-1" instead of "holidays"): CALENDARNAME1,CALENDARNAME2 + +# ADD DIRECTORY OF YOUR LOCAL CLOUD CLIENT +/home/USER/CLOUD From ed84a25785f4a5045a9c810a9133d4f48fee9f01 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Tue, 8 Mar 2022 15:11:30 +0100 Subject: [PATCH 02/54] Add part for local cloud files --- cloud-backup.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cloud-backup.py b/cloud-backup.py index b901fc4..7a09f33 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -8,6 +8,7 @@ import datetime import os import shutil +import zipfile print ("Cloud Backup v.1.1") print ("Feel free to visit trmsc1.wordpress.com") @@ -38,6 +39,8 @@ urlvcf = urlvcf.replace('\n', "") url = content[19] calendarlist = content[23].replace('\n', "").split(",") + clientfolder = content[26] + clientfolder = clientfolder.replace('\n', "") # Check and create storage directory if not os.path.exists(path): @@ -76,6 +79,19 @@ def sorted_ls(path): r = requests.get(urlvcf, auth=(user, passwd),allow_redirects=True) with open(filename, 'wb') as a: a.write(r.content) + +# Copy and zip local client files +clientfile = backupdir + filedate + "-localfiles.zip" +countfiles = 0 +print ("Create " + clientfile + " and ad files...") +with zipfile.ZipFile(clientfile, 'w', zipfile.ZIP_DEFLATED) as target: + for root, dirs, files in os.walk(clientfolder): + for file in files: + add = os.path.join(root, file) + target.write(add) + print("Add " + add) + countfiles +=1 +print (str(countfiles) + " files were added to " + clientfile) # Remove older versions print ("\nClean older versions...") From 216bdd31ba3116c5be75f5845fe3140fa5f98d56 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Tue, 8 Mar 2022 15:44:01 +0100 Subject: [PATCH 03/54] Add duration --- cloud-backup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 7a09f33..a79c4cc 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -1,4 +1,4 @@ -# Cloud Backup v.1.1 - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ +# Cloud Backup v.1.1.filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html # Prepare the backdata.txt and put it in the same directory like this script. @@ -15,6 +15,7 @@ print ("\nCheck data...") # Check date +starttime = datetime.datetime.now() folderdate = datetime.datetime.now().strftime("%Y-%m-%d") filedate = folderdate + datetime.datetime.now().strftime("-%H-%M") print ("Time is " + filedate) @@ -83,7 +84,7 @@ def sorted_ls(path): # Copy and zip local client files clientfile = backupdir + filedate + "-localfiles.zip" countfiles = 0 -print ("Create " + clientfile + " and ad files...") +print ("\nCreate " + clientfile + " and ad files...") with zipfile.ZipFile(clientfile, 'w', zipfile.ZIP_DEFLATED) as target: for root, dirs, files in os.walk(clientfolder): for file in files: @@ -96,10 +97,12 @@ def sorted_ls(path): # Remove older versions print ("\nClean older versions...") if del_list == []: - print ("[]") + print ("none") for dfile in del_list: print ("Removing " + path + dfile) shutil.rmtree(path + dfile) # Finish -print ("\nBackup finished") +endtime = datetime.datetime.now() +duration = endtime - starttime +print ("\nBackup finished after a duration of " + str(duration)) From a72f21ec9f9aae1905ef3a1cd733785816e9e499 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Tue, 8 Mar 2022 15:44:52 +0100 Subject: [PATCH 04/54] Revise versiom --- cloud-backup-data.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-backup-data.txt b/cloud-backup-data.txt index 6b82e46..1e435ff 100644 --- a/cloud-backup-data.txt +++ b/cloud-backup-data.txt @@ -1,4 +1,4 @@ -# Cloud Backup v.1.1 - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ +# Cloud Backup v.1.1.filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html # PUT IN YOUR DATA NEEDED FOR THE BACKUP PROGRESS From e19fb56822317bc8b963c764ea40ae6ff6aa5b66 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Thu, 10 Mar 2022 22:06:09 +0100 Subject: [PATCH 05/54] Create data.ini --- data.ini | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 data.ini diff --git a/data.ini b/data.ini new file mode 100644 index 0000000..5f69e0d --- /dev/null +++ b/data.ini @@ -0,0 +1,14 @@ +[GENERAL] +directory = cloud-backup-storage/ +number = 2 + +[ACCESS] +user = "" +pwd = "" + +[CLOUD] +activate = [0,0,0] +card = "YOURURL/remote.php/dav/adressbooks/users/USERNAME/contacts/" +cal = "YOURURL/remote.php/dav/calendars/USERNAME/" +callist = ["CALENDARNAME1", "CALENDARNAME2"] +client = "/home/USER/CLOUD" From 54738d482019b70eeda284ee1bb9132535d5f55e Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Thu, 10 Mar 2022 22:30:02 +0100 Subject: [PATCH 06/54] Create cloud-backup-settings.py --- cloud-backup-settings.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cloud-backup-settings.py diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py new file mode 100644 index 0000000..8af2f1f --- /dev/null +++ b/cloud-backup-settings.py @@ -0,0 +1,24 @@ +# Cloud Backup v.1.1.filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ +# GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html + +import configparser + +print ("Welcome to the settings for your cloud-backup\n") +print ("v.1.1") + +print ("\nGENERAL") +print ("1 - Change directory") +print ("2 - Number of stored backups") +print ("\nACCESS") +print ("3 - Set username") +print ("4 - Set password") +print ("\nADRESSBOOK") +print ("6 - Activate adressbook backup") +print ("5 - Adressbook url") +print ("\nCALENDAR") +print ("6 - Activate calendar backup") +print ("7 - Calendar url") +print ("8 - Calendar list") +print ("\nDATA") +print ("9 - Activate data backup from desktop client") +print ("10 - Client path") From 0eec2d57796478a8041f9567ee1022d512f65cd3 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Thu, 10 Mar 2022 23:21:46 +0100 Subject: [PATCH 07/54] Update cloud-backup-settings.py --- cloud-backup-settings.py | 57 +++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 8af2f1f..0c37c73 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -3,22 +3,43 @@ import configparser -print ("Welcome to the settings for your cloud-backup\n") -print ("v.1.1") +print ("Welcome to the settings for your cloud-backup (v.1.1)") -print ("\nGENERAL") -print ("1 - Change directory") -print ("2 - Number of stored backups") -print ("\nACCESS") -print ("3 - Set username") -print ("4 - Set password") -print ("\nADRESSBOOK") -print ("6 - Activate adressbook backup") -print ("5 - Adressbook url") -print ("\nCALENDAR") -print ("6 - Activate calendar backup") -print ("7 - Calendar url") -print ("8 - Calendar list") -print ("\nDATA") -print ("9 - Activate data backup from desktop client") -print ("10 - Client path") +def startSettings(): + x = input ("\nDo you want to start the auto (1) or custom (2) settings? Type (3) for exit. ") + x = int(x) + if x==1: + setAuto() + elif x==2: + setCustom() + elif x==3: + exit() + else: + startSettings() + +def setAuto(): + print ("Start auto settings...") + print ("\nGENERAL") + +def setCustom(): + print ("Start custom settings...") + print ("\nGENERAL SETTINGS") + print ("1 - Change directory") + print ("2 - Number of stored backups") + print ("\nACCESS DECLARATIONS") + print ("3 - Set username") + print ("4 - Set password") + print ("\nADRESSBOOK BACKUP") + print ("6 - Activate adressbook backup") + print ("5 - Adressbook url") + print ("\nCALENDAR BACKUP") + print ("6 - Activate calendar backup") + print ("7 - Calendar url") + print ("8 - Calendar list") + print ("\nDATA BACKUP") + print ("9 - Activate data backup from desktop client") + print ("10 - Client path") + x = input ("\nWhich number do you want to change? ") + print (x) + +startSettings() From 56a3859b5b428adc3e8db196656d2a8ff3b510e5 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Thu, 10 Mar 2022 23:24:50 +0100 Subject: [PATCH 08/54] Add username and password --- data.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data.ini b/data.ini index 5f69e0d..b859135 100644 --- a/data.ini +++ b/data.ini @@ -3,8 +3,8 @@ directory = cloud-backup-storage/ number = 2 [ACCESS] -user = "" -pwd = "" +user = "USERNAME" +pwd = "PASSWORD" [CLOUD] activate = [0,0,0] From 8422ed819dd18fdce7cfb30b4a37766c85595bd5 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Thu, 10 Mar 2022 23:32:52 +0100 Subject: [PATCH 09/54] Add variable for transport --- cloud-backup-settings.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 0c37c73..e2c4ea1 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -5,23 +5,24 @@ print ("Welcome to the settings for your cloud-backup (v.1.1)") +depart = 0 def startSettings(): - x = input ("\nDo you want to start the auto (1) or custom (2) settings? Type (3) for exit. ") - x = int(x) - if x==1: - setAuto() - elif x==2: - setCustom() - elif x==3: + depart = input ("\nDo you want to start the auto (1) or custom (2) settings? Type (3) for exit. ") + depart = int(depart) + if depart==1: + setAuto(depart) + elif depart==2: + setCustom(depart) + elif depart==3: exit() else: startSettings() -def setAuto(): +def setAuto(depart): print ("Start auto settings...") print ("\nGENERAL") -def setCustom(): +def setCustom(depart): print ("Start custom settings...") print ("\nGENERAL SETTINGS") print ("1 - Change directory") From 4cdca2e53cbcb727c528b8c93fb88f50f8a16514 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 12 Mar 2022 12:11:58 +0100 Subject: [PATCH 10/54] Add some functions --- cloud-backup-settings.py | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index e2c4ea1..536a0d5 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -2,22 +2,51 @@ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html import configparser +import numbers -print ("Welcome to the settings for your cloud-backup (v.1.1)") +config = configparser.ConfigParser() + +print ("Welcome to the settings for your cloud-backup (v.1.1)\n") -depart = 0 def startSettings(): + val = readData() + printData(val) depart = input ("\nDo you want to start the auto (1) or custom (2) settings? Type (3) for exit. ") depart = int(depart) - if depart==1: + if depart == 1: setAuto(depart) - elif depart==2: + elif depart == 2: setCustom(depart) - elif depart==3: + elif depart == 3: exit() else: startSettings() +def readData(): + config.read ("data.ini") + val = [] + x = 0 + for key in config["GENERAL"]: + val.append(config["GENERAL"][key]) + return (val) + +def printData(val): + encr = "" + x = 0 + while x < len(val[3]): + encr += "*" + x += 1 + + print ("Backup directory: " + val[0]) + print ("Stored backup days: " + val[1]) + print ("Username: " + val[2]) + print ("Password: " + encr) + print ("Adressbook URL: " + val[5]) + print ("Calendar URL: " + val[6]) + print ("Calendar list: " + val[7]) + print ("Local client directory: " + val[8]) + + def setAuto(depart): print ("Start auto settings...") print ("\nGENERAL") From b5a18b5c86d0b3cf781e26ff8e3848c7d26f2a65 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 12 Mar 2022 22:25:02 +0100 Subject: [PATCH 11/54] Fix path of data.ini --- cloud-backup-settings.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 536a0d5..d31459d 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -3,6 +3,7 @@ import configparser import numbers +import os config = configparser.ConfigParser() @@ -23,7 +24,11 @@ def startSettings(): startSettings() def readData(): - config.read ("data.ini") + + data = os.path.dirname(__file__) + data = data + "/data.ini" + print (data) + config.read (data) val = [] x = 0 for key in config["GENERAL"]: From a9517ca9b284dc738139f2828ca6bdeb931dd980 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 11:33:01 +0100 Subject: [PATCH 12/54] Add last modified item --- cloud-backup-settings.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index d31459d..74bac8e 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -38,13 +38,14 @@ def readData(): def printData(val): encr = "" x = 0 - while x < len(val[3]): + while x < len(val[4]): encr += "*" x += 1 - print ("Backup directory: " + val[0]) - print ("Stored backup days: " + val[1]) - print ("Username: " + val[2]) + print ("Last modified: " + val[0]) + print ("Backup directory: " + val[1]) + print ("Stored backup days: " + val[2]) + print ("Username: " + val[3]) print ("Password: " + encr) print ("Adressbook URL: " + val[5]) print ("Calendar URL: " + val[6]) From 263df1ee99f40f92f4844b73fb35a8b2677b2f9b Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 11:33:32 +0100 Subject: [PATCH 13/54] Add last modified item --- data.ini | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/data.ini b/data.ini index b859135..7fec4e6 100644 --- a/data.ini +++ b/data.ini @@ -1,14 +1,11 @@ [GENERAL] +date = none directory = cloud-backup-storage/ number = 2 - -[ACCESS] -user = "USERNAME" -pwd = "PASSWORD" - -[CLOUD] +user = USERNAME +pwd = PASSWORD activate = [0,0,0] -card = "YOURURL/remote.php/dav/adressbooks/users/USERNAME/contacts/" -cal = "YOURURL/remote.php/dav/calendars/USERNAME/" -callist = ["CALENDARNAME1", "CALENDARNAME2"] -client = "/home/USER/CLOUD" +card = YOURURL/remote.php/dav/adressbooks/users/USERNAME/contacts/ +cal = YOURURL/remote.php/dav/calendars/USERNAME/ +callist = CALENDARNAME1, CALENDARNAME2 +client = /home/USER/CLOUD From d717c27f58165530603efc5b721751bdf5b3d6af Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 13:12:28 +0100 Subject: [PATCH 14/54] Further development of functions --- cloud-backup-settings.py | 65 ++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 74bac8e..dc43a9b 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + # Cloud Backup v.1.1.filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html @@ -9,22 +11,24 @@ print ("Welcome to the settings for your cloud-backup (v.1.1)\n") -def startSettings(): +def startMain(): val = readData() printData(val) - depart = input ("\nDo you want to start the auto (1) or custom (2) settings? Type (3) for exit. ") + depart = input ("\nDo you want to start auto (1) or custom (2) settings? Type (x) for exit. ") + if depart == "x": + exit() depart = int(depart) if depart == 1: - setAuto(depart) + startProgress(depart, 1) elif depart == 2: setCustom(depart) - elif depart == 3: + elif depart == 0: exit() else: - startSettings() + startMain() + return def readData(): - data = os.path.dirname(__file__) data = data + "/data.ini" print (data) @@ -41,7 +45,6 @@ def printData(val): while x < len(val[4]): encr += "*" x += 1 - print ("Last modified: " + val[0]) print ("Backup directory: " + val[1]) print ("Stored backup days: " + val[2]) @@ -51,11 +54,7 @@ def printData(val): print ("Calendar URL: " + val[6]) print ("Calendar list: " + val[7]) print ("Local client directory: " + val[8]) - - -def setAuto(depart): - print ("Start auto settings...") - print ("\nGENERAL") + return def setCustom(depart): print ("Start custom settings...") @@ -75,7 +74,43 @@ def setCustom(depart): print ("\nDATA BACKUP") print ("9 - Activate data backup from desktop client") print ("10 - Client path") - x = input ("\nWhich number do you want to change? ") - print (x) + item = input ("\nWhich number do you want to change? Press (x) for exit. ") + if item == "x": + startMain() + else: + item = int(item) + startProgress(depart, item) + return + +def startProgress(depart, item): + val = readData() + print ("") + if depart == 1: + percent = (item - 1) * 10 + print ("Setting progress: " + str(percent) + "%\n") + if item == 1: + place = "directory" + print ("Backup directory is " + str(val[item])) + if item == 2: + place = "number" + print ("Number of stored backup days: " + str(val[item])) + if item == 11 and depart == 1: + input ("Congratulations! Setting ist complete! Press enter to return.") + startMain() + change = input ("Type in a new value or press (x) for exit: ") + if change == "x": + startMain() + else: + config["GENERAL"][place] = change + data = os.path.dirname(__file__) + data = data + "/data.ini" + with open(data, 'w') as configfile: + config.write(configfile) + if depart == 1: + item +=1 + startProgress(depart, item) + elif depart == 2: + startMain() + return -startSettings() +startMain() From 489361d14dfae643132fdcce79d673c06a9a3007 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 13:12:59 +0100 Subject: [PATCH 15/54] Add shebang --- cloud-backup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cloud-backup.py b/cloud-backup.py index a79c4cc..758951d 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + # Cloud Backup v.1.1.filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html From 77195de9551f8903307bc9bc46d0fccc54ecc900 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 13:20:27 +0100 Subject: [PATCH 16/54] Add date and time --- cloud-backup-settings.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index dc43a9b..24d7092 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -6,6 +6,7 @@ import configparser import numbers import os +import datetime config = configparser.ConfigParser() @@ -57,7 +58,8 @@ def printData(val): return def setCustom(depart): - print ("Start custom settings...") + val = readData() + print ("Last modified: " + val[0]) print ("\nGENERAL SETTINGS") print ("1 - Change directory") print ("2 - Number of stored backups") @@ -102,6 +104,7 @@ def startProgress(depart, item): startMain() else: config["GENERAL"][place] = change + config["GENERAL"]["date"] = datetime.datetime.now().strftime("%Y-%m-%d / %H-%M") data = os.path.dirname(__file__) data = data + "/data.ini" with open(data, 'w') as configfile: From f658517963107a097c8e7784988a256db86ecf8b Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 13:50:02 +0100 Subject: [PATCH 17/54] Change activation items --- data.ini | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/data.ini b/data.ini index 7fec4e6..b84bd8d 100644 --- a/data.ini +++ b/data.ini @@ -1,11 +1,13 @@ [GENERAL] -date = none +date = 2022-03-13 / 13-19 directory = cloud-backup-storage/ number = 2 user = USERNAME pwd = PASSWORD -activate = [0,0,0] +cardAct = 0 card = YOURURL/remote.php/dav/adressbooks/users/USERNAME/contacts/ +calAct = 0 cal = YOURURL/remote.php/dav/calendars/USERNAME/ callist = CALENDARNAME1, CALENDARNAME2 +clientAct = 0 client = /home/USER/CLOUD From eb785678bf7f791d9e266190db9b17b0a70f7c09 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 13:57:54 +0100 Subject: [PATCH 18/54] Correct date --- data.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data.ini b/data.ini index b84bd8d..d18c4c1 100644 --- a/data.ini +++ b/data.ini @@ -1,5 +1,5 @@ [GENERAL] -date = 2022-03-13 / 13-19 +date = - directory = cloud-backup-storage/ number = 2 user = USERNAME From 0ee28153d03ee64ee2029873c43b7f9a0877dbfb Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 14:36:50 +0100 Subject: [PATCH 19/54] Expand functions --- cloud-backup-settings.py | 75 +++++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 24d7092..cfa62d4 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -47,14 +47,17 @@ def printData(val): encr += "*" x += 1 print ("Last modified: " + val[0]) - print ("Backup directory: " + val[1]) + print ("\nBackup directory: " + val[1]) print ("Stored backup days: " + val[2]) - print ("Username: " + val[3]) + print ("\nUsername: " + val[3]) print ("Password: " + encr) - print ("Adressbook URL: " + val[5]) - print ("Calendar URL: " + val[6]) - print ("Calendar list: " + val[7]) - print ("Local client directory: " + val[8]) + print ("\nAdressbook storage activated: " + val[5]) + print ("Adressbook URL: " + val[6]) + print ("\nCalendar storage activated: " + val[7]) + print ("Calendar URL: " + val[8]) + print ("Calendar list: " + val[9]) + print ("\nClient storage activated: " + val[10]) + print ("Local client directory: " + val[11]) return def setCustom(depart): @@ -67,15 +70,15 @@ def setCustom(depart): print ("3 - Set username") print ("4 - Set password") print ("\nADRESSBOOK BACKUP") - print ("6 - Activate adressbook backup") - print ("5 - Adressbook url") + print ("5 - Activate adressbook backup") + print ("6 - Adressbook url") print ("\nCALENDAR BACKUP") - print ("6 - Activate calendar backup") - print ("7 - Calendar url") - print ("8 - Calendar list") + print ("7 - Activate calendar backup") + print ("8 - Calendar url") + print ("9 - Calendar list") print ("\nDATA BACKUP") - print ("9 - Activate data backup from desktop client") - print ("10 - Client path") + print ("10 - Activate data backup from desktop client") + print ("11 - Client path") item = input ("\nWhich number do you want to change? Press (x) for exit. ") if item == "x": startMain() @@ -96,12 +99,52 @@ def startProgress(depart, item): if item == 2: place = "number" print ("Number of stored backup days: " + str(val[item])) + if item == 3: + place = "user" + print ("Username is: " + str(val[item])) + if item == 4: + place = "pwd" + print ("Password is: " + str(val[item])) + if item == 5: + place = "cardAct" + print ("Adressbook storage activated: " + str(val[item])) + if item == 6: + place = "card" + print ("Adressbook URL is: " + str(val[item])) + if item == 7: + place = "calAct" + print ("Calendar storage activated: " + str(val[item])) + if item == 8: + place = "cal" + print ("Calendar URL is: " + str(val[item])) + if item == 9: + place = "callist" + print ("Calendar URL is: " + str(val[item])) + if item == 10: + place = "clientAct" + print ("Client storage activated: " + str(val[item])) + if item == 11: + place = "client" + print ("Client path is: " + str(val[item])) if item == 11 and depart == 1: input ("Congratulations! Setting ist complete! Press enter to return.") startMain() - change = input ("Type in a new value or press (x) for exit: ") - if change == "x": + + if item == 5 or item == 7 or item == 10: + change = input ("Type (0) for deactivate, (1) for activate or press (x) for exit: ") + if change == "0": + change = "false" + elif change == "1": + change = "true" + # remaining: encrypt password input + # remaining: calendarlist + else: + change = input ("Type in a new value or press (x) for exit: ") + + if change == "x" and depart == 1: startMain() + elif change == "x" and depart == 2: + setCustom(depart) else: config["GENERAL"][place] = change config["GENERAL"]["date"] = datetime.datetime.now().strftime("%Y-%m-%d / %H-%M") @@ -113,7 +156,7 @@ def startProgress(depart, item): item +=1 startProgress(depart, item) elif depart == 2: - startMain() + setCustom(depart) return startMain() From ff12db7d1faa948ac37c03d853cd74ce776a729a Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 23:10:33 +0100 Subject: [PATCH 20/54] Add encrypted password function --- cloud-backup-settings.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index cfa62d4..80b0629 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -7,6 +7,7 @@ import numbers import os import datetime +import getpass config = configparser.ConfigParser() @@ -41,11 +42,7 @@ def readData(): return (val) def printData(val): - encr = "" - x = 0 - while x < len(val[4]): - encr += "*" - x += 1 + encr = encryptPwd(val) print ("Last modified: " + val[0]) print ("\nBackup directory: " + val[1]) print ("Stored backup days: " + val[2]) @@ -60,6 +57,14 @@ def printData(val): print ("Local client directory: " + val[11]) return +def encryptPwd(val): + encr = "" + x = 0 + while x < len(val[4]): + encr += "*" + x += 1 + return encr + def setCustom(depart): val = readData() print ("Last modified: " + val[0]) @@ -79,7 +84,7 @@ def setCustom(depart): print ("\nDATA BACKUP") print ("10 - Activate data backup from desktop client") print ("11 - Client path") - item = input ("\nWhich number do you want to change? Press (x) for exit. ") + item = input ("\nWhich number do you want to change? Press (x) for abort. ") if item == "x": startMain() else: @@ -103,8 +108,9 @@ def startProgress(depart, item): place = "user" print ("Username is: " + str(val[item])) if item == 4: + encr = encryptPwd(val) place = "pwd" - print ("Password is: " + str(val[item])) + print ("Password is: " + encr) if item == 5: place = "cardAct" print ("Adressbook storage activated: " + str(val[item])) @@ -131,15 +137,17 @@ def startProgress(depart, item): startMain() if item == 5 or item == 7 or item == 10: - change = input ("Type (0) for deactivate, (1) for activate or press (x) for exit: ") + change = input ("Type (0) for deactivate, (1) for activate or press (x) for abort: ") if change == "0": change = "false" elif change == "1": change = "true" - # remaining: encrypt password input + elif item == 4: + change = getpass.getpass ("Type in your password or press (x) for abort. Input is hidden: ") + # remaining: calendarlist else: - change = input ("Type in a new value or press (x) for exit: ") + change = input ("Type in a new value or press (x) for abort: ") if change == "x" and depart == 1: startMain() From 913de1e304fc0c813d1c5af02ced99a49ff1a723 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 13 Mar 2022 23:14:12 +0100 Subject: [PATCH 21/54] Add colon --- cloud-backup-settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 80b0629..874a439 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -100,7 +100,7 @@ def startProgress(depart, item): print ("Setting progress: " + str(percent) + "%\n") if item == 1: place = "directory" - print ("Backup directory is " + str(val[item])) + print ("Backup directory is: " + str(val[item])) if item == 2: place = "number" print ("Number of stored backup days: " + str(val[item])) From cae9b5c6a9000e47d2e0df63658890bde3b0cd32 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 20 Mar 2022 11:47:13 +0100 Subject: [PATCH 22/54] Change activation from true/ false to yes/ no --- data.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data.ini b/data.ini index d18c4c1..d68a4cc 100644 --- a/data.ini +++ b/data.ini @@ -4,10 +4,10 @@ directory = cloud-backup-storage/ number = 2 user = USERNAME pwd = PASSWORD -cardAct = 0 +cardAct = no card = YOURURL/remote.php/dav/adressbooks/users/USERNAME/contacts/ -calAct = 0 +calAct = no cal = YOURURL/remote.php/dav/calendars/USERNAME/ callist = CALENDARNAME1, CALENDARNAME2 -clientAct = 0 +clientAct = no client = /home/USER/CLOUD From a6348d5a6d987af8887a22d03717b3572fe565e1 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 20 Mar 2022 11:48:57 +0100 Subject: [PATCH 23/54] Add function for calendarlist --- cloud-backup-settings.py | 60 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 874a439..87d16d8 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -8,6 +8,7 @@ import os import datetime import getpass +from pickle import TRUE config = configparser.ConfigParser() @@ -33,7 +34,6 @@ def startMain(): def readData(): data = os.path.dirname(__file__) data = data + "/data.ini" - print (data) config.read (data) val = [] x = 0 @@ -125,7 +125,7 @@ def startProgress(depart, item): print ("Calendar URL is: " + str(val[item])) if item == 9: place = "callist" - print ("Calendar URL is: " + str(val[item])) + print ("Calendarlist is: " + str(val[item])) if item == 10: place = "clientAct" print ("Client storage activated: " + str(val[item])) @@ -139,20 +139,24 @@ def startProgress(depart, item): if item == 5 or item == 7 or item == 10: change = input ("Type (0) for deactivate, (1) for activate or press (x) for abort: ") if change == "0": - change = "false" + change = "no" elif change == "1": - change = "true" + change = "yes" elif item == 4: change = getpass.getpass ("Type in your password or press (x) for abort. Input is hidden: ") - - # remaining: calendarlist + elif item == 9: + # ONLY CHECK AND EDIT VALUES, THEN COME BACK + change = openList () else: change = input ("Type in a new value or press (x) for abort: ") + change = str(change) if change == "x" and depart == 1: startMain() + return elif change == "x" and depart == 2: setCustom(depart) + return else: config["GENERAL"][place] = change config["GENERAL"]["date"] = datetime.datetime.now().strftime("%Y-%m-%d / %H-%M") @@ -167,4 +171,48 @@ def startProgress(depart, item): setCustom(depart) return +def openList (): + val = readData() + calendarlist = val[9].replace('\n', "").split(",") + listcontent = val[9] + choice = "" + while choice != "x": + items = len(calendarlist) + itemsDisp = items + 1 + position = 0 + print("") + if position == items: + print ("No calendarlists...") + else: + while position < items: + posDisp = position + 1 + valDisp = calendarlist[position] + print (str(posDisp) + " - " + valDisp) + position += 1 + choice = input("Type in a new calendar name, type an item number for deleting or type (x) to finish. ") + isInt = True + try: + int(choice) + except ValueError: + isInt = False + if isInt and int(choice) < itemsDisp: + print ("YES") + choice = int(choice) - 1 + del calendarlist[choice] + listcontent = ",".join(calendarlist) + print(listcontent) + elif isInt and int(choice) >= itemsDisp: + print ("CALENDAR DOES NOT EXIST.") + elif choice != "x": + listcontent = listcontent + "," + choice + calendarlist = listcontent.replace('\n', "").split(",") + print (listcontent) + print ("\nOld version: " + val[9]) + print ("New version: " + listcontent) + choice = input ("Press (x) to abort or press only enter ro save. ") + if choice == "x": + return val[9] + else: + return listcontent + startMain() From f0bc481ddaa4c960bf204fde719a1c9b82f0a7c7 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 20 Mar 2022 12:59:57 +0100 Subject: [PATCH 24/54] Some auto setup fixes --- cloud-backup-settings.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 87d16d8..fd76752 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -12,7 +12,7 @@ config = configparser.ConfigParser() -print ("Welcome to the settings for your cloud-backup (v.1.1)\n") +print ("\nWelcome to cloud-backup configuration (v.1.1)\n") def startMain(): val = readData() @@ -95,9 +95,9 @@ def setCustom(depart): def startProgress(depart, item): val = readData() print ("") - if depart == 1: - percent = (item - 1) * 10 - print ("Setting progress: " + str(percent) + "%\n") + if depart == 1 and item < 12: + percent = (item - 1) * 9 + print ("### Setting progress: " + str(percent) + "% ###\n") if item == 1: place = "directory" print ("Backup directory is: " + str(val[item])) @@ -132,9 +132,11 @@ def startProgress(depart, item): if item == 11: place = "client" print ("Client path is: " + str(val[item])) - if item == 11 and depart == 1: + if item == 12 and depart == 1: + print ("### Setting progress: 90% ###\n") input ("Congratulations! Setting ist complete! Press enter to return.") startMain() + return if item == 5 or item == 7 or item == 10: change = input ("Type (0) for deactivate, (1) for activate or press (x) for abort: ") @@ -175,8 +177,8 @@ def openList (): val = readData() calendarlist = val[9].replace('\n', "").split(",") listcontent = val[9] - choice = "" - while choice != "x": + choice = "x" + while choice != "": items = len(calendarlist) itemsDisp = items + 1 position = 0 @@ -189,7 +191,7 @@ def openList (): valDisp = calendarlist[position] print (str(posDisp) + " - " + valDisp) position += 1 - choice = input("Type in a new calendar name, type an item number for deleting or type (x) to finish. ") + choice = input("Type in a new calendar name, type an item number for deleting or press enter to finish. ") isInt = True try: int(choice) @@ -203,13 +205,13 @@ def openList (): print(listcontent) elif isInt and int(choice) >= itemsDisp: print ("CALENDAR DOES NOT EXIST.") - elif choice != "x": + elif choice != "": listcontent = listcontent + "," + choice calendarlist = listcontent.replace('\n', "").split(",") print (listcontent) print ("\nOld version: " + val[9]) print ("New version: " + listcontent) - choice = input ("Press (x) to abort or press only enter ro save. ") + choice = input ("Press (x) to discard changes or press enter to save. ") if choice == "x": return val[9] else: From a5180ac6557d5a6d7b5685abdaa79a802beb03ca Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 20 Mar 2022 20:16:59 +0100 Subject: [PATCH 25/54] Generalize config file path --- cloud-backup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloud-backup.py b/cloud-backup.py index 758951d..d40345e 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -23,7 +23,9 @@ print ("Time is " + filedate) # Check data -with open("cloud-backup-data.txt", "r") as backdata: +config = os.path.dirname(__file__) +config = config + "/cloud-backup-data.txt" +with open(data, "r") as backdata: content = backdata.readlines () path = content[6] path = path.replace('\n', "") From 8a031c1cf5f2525a3027b289c1992d72eb872aa8 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 20 Mar 2022 20:18:37 +0100 Subject: [PATCH 26/54] Add unit for duration (s) --- cloud-backup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-backup.py b/cloud-backup.py index d40345e..adcf21d 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -109,4 +109,4 @@ def sorted_ls(path): # Finish endtime = datetime.datetime.now() duration = endtime - starttime -print ("\nBackup finished after a duration of " + str(duration)) +print ("\nBackup finished after a duration of " + str(duration) + "s.") From e9f5e4d832cea29bbd54d91bdaeee789d0ed647e Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sun, 20 Mar 2022 21:52:09 +0100 Subject: [PATCH 27/54] Start combining main functions --- cloud-backup-settings.py | 61 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index fd76752..a224210 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -12,7 +12,7 @@ config = configparser.ConfigParser() -print ("\nWelcome to cloud-backup configuration (v.1.1)\n") +print ("\nWELCOME TO CLOUD-BACKUP CONFIGURATION (v.1.1)\n") def startMain(): val = readData() @@ -67,29 +67,27 @@ def encryptPwd(val): def setCustom(depart): val = readData() - print ("Last modified: " + val[0]) - print ("\nGENERAL SETTINGS") - print ("1 - Change directory") - print ("2 - Number of stored backups") - print ("\nACCESS DECLARATIONS") - print ("3 - Set username") - print ("4 - Set password") - print ("\nADRESSBOOK BACKUP") - print ("5 - Activate adressbook backup") - print ("6 - Adressbook url") - print ("\nCALENDAR BACKUP") - print ("7 - Activate calendar backup") - print ("8 - Calendar url") - print ("9 - Calendar list") - print ("\nDATA BACKUP") - print ("10 - Activate data backup from desktop client") - print ("11 - Client path") - item = input ("\nWhich number do you want to change? Press (x) for abort. ") + encr = encryptPwd(val) + print ("Last modified: " + val[0] + "\n") + print (" 1 - GENERAL - Change backup directory (" + val[1] + ")") + print (" 2 - GENERAL - Number of stored backups (" + val[2] + ")") + print (" 3 - ACCESS - Set username (" + val[3] + ")") + print (" 4 - ACCESS - Set password (" + encr + ")") + print (" 5 - ADRESSBOOK - Activate adressbook backup (" + val[5] + ")") + print (" 6 - ADRESSBOOK - Adressbook url (" + val[6] + ")") + print (" 7 - CALENDAR - Activate calendar backup (" + val[7] + ")") + print (" 8 - CALENDAR - Calendar url (" + val[8] + ")") + print (" 9 - CALENDAR - Calendar list (" + val[9] + ")") + print ("10 - DATA - Activate data backup from desktop client (" + val[10] + ")") + print ("11 - DATA - Client path (" + val[11] + ")") + item = input ("\nPress enter to start auto settings, type (x) to exit or type in the number you want to change. ") if item == "x": - startMain() + exit() + elif item == "": + startProgress(1, 1) else: item = int(item) - startProgress(depart, item) + startProgress(2, item) return def startProgress(depart, item): @@ -139,24 +137,31 @@ def startProgress(depart, item): return if item == 5 or item == 7 or item == 10: - change = input ("Type (0) for deactivate, (1) for activate or press (x) for abort: ") + change = input ("Type (0) for deactivate, (1) for activate or press enter to skip: ") if change == "0": change = "no" elif change == "1": change = "yes" elif item == 4: - change = getpass.getpass ("Type in your password or press (x) for abort. Input is hidden: ") + change = getpass.getpass ("Type in your password or press enter to skip. Input is hidden: ") elif item == 9: # ONLY CHECK AND EDIT VALUES, THEN COME BACK change = openList () else: - change = input ("Type in a new value or press (x) for abort: ") + if depart == 1: + change = input ("Type in a new value, type (x) to abort or press enter to skip: ") + elif depart == 2: + change = input ("Type in a new value or press enter to abort: ") change = str(change) - if change == "x" and depart == 1: - startMain() + if change == "" and depart == 1: + item = int(item) + 1 + startProgress(1, item) return - elif change == "x" and depart == 2: + elif change == "x" and depart == 1: + setCustom(depart) + return + elif change == "" and depart == 2: setCustom(depart) return else: @@ -191,7 +196,7 @@ def openList (): valDisp = calendarlist[position] print (str(posDisp) + " - " + valDisp) position += 1 - choice = input("Type in a new calendar name, type an item number for deleting or press enter to finish. ") + choice = input("Type in a new calendar name, type an item number for deleting or press enter to skip/ finish. ") isInt = True try: int(choice) From 2825858af7ac4ba34d76cd460cfa1e530db9d729 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Wed, 23 Mar 2022 07:01:07 +0100 Subject: [PATCH 28/54] Prevent wrong inputs --- cloud-backup-settings.py | 150 +++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 68 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index a224210..95f1699 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -10,25 +10,38 @@ import getpass from pickle import TRUE -config = configparser.ConfigParser() - -print ("\nWELCOME TO CLOUD-BACKUP CONFIGURATION (v.1.1)\n") - -def startMain(): +def setCustom(depart): + depart = 0 val = readData() - printData(val) - depart = input ("\nDo you want to start auto (1) or custom (2) settings? Type (x) for exit. ") - if depart == "x": - exit() - depart = int(depart) - if depart == 1: - startProgress(depart, 1) - elif depart == 2: - setCustom(depart) - elif depart == 0: - exit() - else: - startMain() + encr = encryptPwd(val) + print ("Last modified: " + val[0] + "\n") + print (" 1 - GENERAL - Change backup directory (" + val[1] + ")") + print (" 2 - GENERAL - Number of stored backups (" + val[2] + ")") + print (" 3 - ACCESS - Set username (" + val[3] + ")") + print (" 4 - ACCESS - Set password (" + encr + ")") + print (" 5 - ADRESSBOOK - Activate adressbook backup (" + val[5] + ")") + print (" 6 - ADRESSBOOK - Adressbook url (" + val[6] + ")") + print (" 7 - CALENDAR - Activate calendar backup (" + val[7] + ")") + print (" 8 - CALENDAR - Calendar url (" + val[8] + ")") + print (" 9 - CALENDAR - Calendar list (" + val[9] + ")") + print ("10 - DATA - Activate data backup from desktop client (" + val[10] + ")") + print ("11 - DATA - Client path (" + val[11] + ")") + print ("") + check = 0 + while check == 0: + item = input ("Press enter to start auto settings, type (x) to exit or type in the number you want to change. ") + if item == "x": + exit() + elif item == "": + startProgress(1, 1) + check = 1 + else: + item = int(item) + if item > 0 and item <= 11: + startProgress(2, item) + check = 1 + else: + check = 0 return def readData(): @@ -41,22 +54,6 @@ def readData(): val.append(config["GENERAL"][key]) return (val) -def printData(val): - encr = encryptPwd(val) - print ("Last modified: " + val[0]) - print ("\nBackup directory: " + val[1]) - print ("Stored backup days: " + val[2]) - print ("\nUsername: " + val[3]) - print ("Password: " + encr) - print ("\nAdressbook storage activated: " + val[5]) - print ("Adressbook URL: " + val[6]) - print ("\nCalendar storage activated: " + val[7]) - print ("Calendar URL: " + val[8]) - print ("Calendar list: " + val[9]) - print ("\nClient storage activated: " + val[10]) - print ("Local client directory: " + val[11]) - return - def encryptPwd(val): encr = "" x = 0 @@ -65,34 +62,11 @@ def encryptPwd(val): x += 1 return encr -def setCustom(depart): - val = readData() - encr = encryptPwd(val) - print ("Last modified: " + val[0] + "\n") - print (" 1 - GENERAL - Change backup directory (" + val[1] + ")") - print (" 2 - GENERAL - Number of stored backups (" + val[2] + ")") - print (" 3 - ACCESS - Set username (" + val[3] + ")") - print (" 4 - ACCESS - Set password (" + encr + ")") - print (" 5 - ADRESSBOOK - Activate adressbook backup (" + val[5] + ")") - print (" 6 - ADRESSBOOK - Adressbook url (" + val[6] + ")") - print (" 7 - CALENDAR - Activate calendar backup (" + val[7] + ")") - print (" 8 - CALENDAR - Calendar url (" + val[8] + ")") - print (" 9 - CALENDAR - Calendar list (" + val[9] + ")") - print ("10 - DATA - Activate data backup from desktop client (" + val[10] + ")") - print ("11 - DATA - Client path (" + val[11] + ")") - item = input ("\nPress enter to start auto settings, type (x) to exit or type in the number you want to change. ") - if item == "x": - exit() - elif item == "": - startProgress(1, 1) - else: - item = int(item) - startProgress(2, item) - return - def startProgress(depart, item): val = readData() + check = 0 print ("") + # Print items and values if depart == 1 and item < 12: percent = (item - 1) * 9 print ("### Setting progress: " + str(percent) + "% ###\n") @@ -135,17 +109,21 @@ def startProgress(depart, item): input ("Congratulations! Setting ist complete! Press enter to return.") startMain() return - + # Input actions if item == 5 or item == 7 or item == 10: - change = input ("Type (0) for deactivate, (1) for activate or press enter to skip: ") - if change == "0": - change = "no" - elif change == "1": - change = "yes" + while check == 0: + change = input ("Type (0) for deactivate, (1) for activate or press enter to skip: ") + if change == "0": + change = "no" + check = 1 + elif change == "1": + change = "yes" + check = 1 + elif change == "": + check = 1 elif item == 4: change = getpass.getpass ("Type in your password or press enter to skip. Input is hidden: ") elif item == 9: - # ONLY CHECK AND EDIT VALUES, THEN COME BACK change = openList () else: if depart == 1: @@ -153,7 +131,6 @@ def startProgress(depart, item): elif depart == 2: change = input ("Type in a new value or press enter to abort: ") change = str(change) - if change == "" and depart == 1: item = int(item) + 1 startProgress(1, item) @@ -221,5 +198,42 @@ def openList (): return val[9] else: return listcontent + +# NECCESSARY??? +def startMain(): + val = readData() + printData(val) + depart = input ("\nDo you want to start auto (1) or custom (2) settings? Type (x) for exit. ") + if depart == "x": + exit() + depart = int(depart) + if depart == 1: + startProgress(depart, 1) + elif depart == 2: + setCustom(depart) + elif depart == 0: + exit() + else: + startMain() + return + +def printData(val): + encr = encryptPwd(val) + print ("Last modified: " + val[0]) + print ("\nBackup directory: " + val[1]) + print ("Stored backup days: " + val[2]) + print ("\nUsername: " + val[3]) + print ("Password: " + encr) + print ("\nAdressbook storage activated: " + val[5]) + print ("Adressbook URL: " + val[6]) + print ("\nCalendar storage activated: " + val[7]) + print ("Calendar URL: " + val[8]) + print ("Calendar list: " + val[9]) + print ("\nClient storage activated: " + val[10]) + print ("Local client directory: " + val[11]) + return -startMain() +config = configparser.ConfigParser() +depart = 0 +print ("\nWELCOME TO CLOUD-BACKUP CONFIGURATION (v.1.1)\n") +setCustom(depart) From fb9b284049e4f2589c06770df386983da1d9f18d Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Fri, 25 Mar 2022 07:29:59 +0100 Subject: [PATCH 29/54] Remove unused parts --- cloud-backup-settings.py | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 95f1699..1ea1ab0 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -107,7 +107,7 @@ def startProgress(depart, item): if item == 12 and depart == 1: print ("### Setting progress: 90% ###\n") input ("Congratulations! Setting ist complete! Press enter to return.") - startMain() + setCustom() return # Input actions if item == 5 or item == 7 or item == 10: @@ -198,40 +198,6 @@ def openList (): return val[9] else: return listcontent - -# NECCESSARY??? -def startMain(): - val = readData() - printData(val) - depart = input ("\nDo you want to start auto (1) or custom (2) settings? Type (x) for exit. ") - if depart == "x": - exit() - depart = int(depart) - if depart == 1: - startProgress(depart, 1) - elif depart == 2: - setCustom(depart) - elif depart == 0: - exit() - else: - startMain() - return - -def printData(val): - encr = encryptPwd(val) - print ("Last modified: " + val[0]) - print ("\nBackup directory: " + val[1]) - print ("Stored backup days: " + val[2]) - print ("\nUsername: " + val[3]) - print ("Password: " + encr) - print ("\nAdressbook storage activated: " + val[5]) - print ("Adressbook URL: " + val[6]) - print ("\nCalendar storage activated: " + val[7]) - print ("Calendar URL: " + val[8]) - print ("Calendar list: " + val[9]) - print ("\nClient storage activated: " + val[10]) - print ("Local client directory: " + val[11]) - return config = configparser.ConfigParser() depart = 0 From 5aa03a0bf600b9f79717289e202e3f4e9ff165aa Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Fri, 25 Mar 2022 23:48:55 +0100 Subject: [PATCH 30/54] Rename and fix calendarlist function --- cloud-backup-settings.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 1ea1ab0..ac943dd 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -10,8 +10,7 @@ import getpass from pickle import TRUE -def setCustom(depart): - depart = 0 +def initConfig(): val = readData() encr = encryptPwd(val) print ("Last modified: " + val[0] + "\n") @@ -107,7 +106,7 @@ def startProgress(depart, item): if item == 12 and depart == 1: print ("### Setting progress: 90% ###\n") input ("Congratulations! Setting ist complete! Press enter to return.") - setCustom() + initConfig() return # Input actions if item == 5 or item == 7 or item == 10: @@ -124,7 +123,7 @@ def startProgress(depart, item): elif item == 4: change = getpass.getpass ("Type in your password or press enter to skip. Input is hidden: ") elif item == 9: - change = openList () + change = openCallist () else: if depart == 1: change = input ("Type in a new value, type (x) to abort or press enter to skip: ") @@ -136,10 +135,10 @@ def startProgress(depart, item): startProgress(1, item) return elif change == "x" and depart == 1: - setCustom(depart) + initConfig() return - elif change == "" and depart == 2: - setCustom(depart) + elif change == "" and depart == 2 and item != 9: + initConfig() return else: config["GENERAL"][place] = change @@ -152,10 +151,10 @@ def startProgress(depart, item): item +=1 startProgress(depart, item) elif depart == 2: - setCustom(depart) + initConfig() return -def openList (): +def openCallist (): val = readData() calendarlist = val[9].replace('\n', "").split(",") listcontent = val[9] @@ -180,7 +179,6 @@ def openList (): except ValueError: isInt = False if isInt and int(choice) < itemsDisp: - print ("YES") choice = int(choice) - 1 del calendarlist[choice] listcontent = ",".join(calendarlist) @@ -200,6 +198,5 @@ def openList (): return listcontent config = configparser.ConfigParser() -depart = 0 print ("\nWELCOME TO CLOUD-BACKUP CONFIGURATION (v.1.1)\n") -setCustom(depart) +initConfig() From 1f3be942b1afe758fef7539d2aa5e32e3429d613 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 26 Mar 2022 00:10:11 +0100 Subject: [PATCH 31/54] Add seperators, fix percent --- cloud-backup-settings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index ac943dd..37c1831 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -13,6 +13,7 @@ def initConfig(): val = readData() encr = encryptPwd(val) + print ("\n- - - - - - - - - - - - - - - - -") print ("Last modified: " + val[0] + "\n") print (" 1 - GENERAL - Change backup directory (" + val[1] + ")") print (" 2 - GENERAL - Number of stored backups (" + val[2] + ")") @@ -68,6 +69,7 @@ def startProgress(depart, item): # Print items and values if depart == 1 and item < 12: percent = (item - 1) * 9 + print ("- - - - - - - - - - - - - - -") print ("### Setting progress: " + str(percent) + "% ###\n") if item == 1: place = "directory" @@ -104,7 +106,8 @@ def startProgress(depart, item): place = "client" print ("Client path is: " + str(val[item])) if item == 12 and depart == 1: - print ("### Setting progress: 90% ###\n") + print ("- - - - - - - - - - - - - - -") + print ("### Setting progress: 100% ###\n") input ("Congratulations! Setting ist complete! Press enter to return.") initConfig() return @@ -198,5 +201,5 @@ def openCallist (): return listcontent config = configparser.ConfigParser() -print ("\nWELCOME TO CLOUD-BACKUP CONFIGURATION (v.1.1)\n") +print ("\nWELCOME TO CLOUD-BACKUP CONFIGURATION (v.1.1)") initConfig() From eba6a005e79f9d215426494701f484d2bba21de5 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 26 Mar 2022 00:20:40 +0100 Subject: [PATCH 32/54] Add source after welcome line --- cloud-backup-settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 37c1831..1fe5918 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -201,5 +201,6 @@ def openCallist (): return listcontent config = configparser.ConfigParser() -print ("\nWELCOME TO CLOUD-BACKUP CONFIGURATION (v.1.1)") +print ("\nWelcome to cloud-backup configuration v.1.1") +print ("Feel free to visit trmsc1.wordpress.com") initConfig() From cef4bb96f9e68fb3979f7d7ee45d7dab98061202 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Thu, 7 Apr 2022 16:12:57 +0200 Subject: [PATCH 33/54] Get data by configparser --- cloud-backup.py | 60 +++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index adcf21d..f2aa811 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -1,18 +1,22 @@ -#!/usr/bin/env python - -# Cloud Backup v.1.1.filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ +# Cloud Backup v.1.1 - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html # Prepare the backdata.txt and put it in the same directory like this script. # Then you can backup your calendars and adressbook directly from the cloud. +import configparser import requests import datetime import os import shutil import zipfile -print ("Cloud Backup v.1.1") +def checkSlash(check): + if check[-1] != "/": + check = check + "/" + return check + +print ("Cloud Backup v.1.1filedev") print ("Feel free to visit trmsc1.wordpress.com") print ("\nCheck data...") @@ -23,29 +27,27 @@ print ("Time is " + filedate) # Check data -config = os.path.dirname(__file__) -config = config + "/cloud-backup-data.txt" -with open(data, "r") as backdata: - content = backdata.readlines () - path = content[6] - path = path.replace('\n', "") - backupdir = path + folderdate + "/" - backupdir = backupdir.replace('\n', "") - print ("Backup directory is " + backupdir) - maintain = content[9] - maintain = maintain.replace('\n', "") - print (maintain + " older subdirectories will be stored\n") - maintain = int(maintain) - user = content[12] - user = user.replace('\n', "") - passwd = content[13] - passwd = passwd.replace('\n', "") - urlvcf = content[16] + "?export" - urlvcf = urlvcf.replace('\n', "") - url = content[19] - calendarlist = content[23].replace('\n', "").split(",") - clientfolder = content[26] - clientfolder = clientfolder.replace('\n', "") +config = configparser.ConfigParser() +data = os.path.dirname(__file__) +data = data + "/data.ini" +config.read (data) +val = [] +x = 0 +for key in config["GENERAL"]: + val.append(config["GENERAL"][key]) +path = checkSlash(val[1]) +backupdir = path + folderdate + "/" +print ("Backup directory is " + backupdir) +maintain = val[2] +print (maintain + " older subdirectories will be stored\n") +maintain = int(maintain) +user = val[3] +passwd = val[4] +urlvcf = checkSlash(val[6]) +url = checkSlash(val[8]) +calendarlist = val[9].replace('\n', "").split(",") +clientfolder = val[11] +clientfolder = clientfolder.replace('\n', "") # Check and create storage directory if not os.path.exists(path): @@ -88,7 +90,7 @@ def sorted_ls(path): # Copy and zip local client files clientfile = backupdir + filedate + "-localfiles.zip" countfiles = 0 -print ("\nCreate " + clientfile + " and ad files...") +print ("\nCreate " + clientfile + " and add files...") with zipfile.ZipFile(clientfile, 'w', zipfile.ZIP_DEFLATED) as target: for root, dirs, files in os.walk(clientfolder): for file in files: @@ -109,4 +111,4 @@ def sorted_ls(path): # Finish endtime = datetime.datetime.now() duration = endtime - starttime -print ("\nBackup finished after a duration of " + str(duration) + "s.") +print ("\nBackup finished after a duration of " + str(duration)) From 2cd8e5d6191b1b51f42df24da9f1f6b89e9e3bbb Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Thu, 7 Apr 2022 16:26:14 +0200 Subject: [PATCH 34/54] Revise description --- cloud-backup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloud-backup.py b/cloud-backup.py index f2aa811..83d0f1a 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -1,8 +1,9 @@ # Cloud Backup v.1.1 - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html -# Prepare the backdata.txt and put it in the same directory like this script. +# Please define your data with the tool "cloud-backup-settings.py" at first. # Then you can backup your calendars and adressbook directly from the cloud. +# If you want to store your data-directory also, the desktop-client has to be installed. import configparser import requests From 68cce5080ab6661126faad6dd45424c8ae692578 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Thu, 7 Apr 2022 16:27:32 +0200 Subject: [PATCH 35/54] No more need because of using the .ini file --- cloud-backup-data.txt | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 cloud-backup-data.txt diff --git a/cloud-backup-data.txt b/cloud-backup-data.txt deleted file mode 100644 index 1e435ff..0000000 --- a/cloud-backup-data.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Cloud Backup v.1.1.filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ -# GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html - -# PUT IN YOUR DATA NEEDED FOR THE BACKUP PROGRESS - -# Change the backup directory or use the default: -cloud-backup-storage/ - -# Number of subdirectories for backup days that should be stored: -2 - -# Add your accessdata: -YOURUSERNAME -YOURPASSWORD - -# Add the URL for your adressbook: -YOURURL/remote.php/dav/adressbooks/users/USERNAME/contacts/ - -# Add the URL for your calendar: -YOURURL/remote.php/dav/calendars/USERNAME/ - -# List your calendar names with commas and no spaces. -# Maybe you have to check the individual urls for the correct deposited names (e.g. "holidays-1" instead of "holidays"): -CALENDARNAME1,CALENDARNAME2 - -# ADD DIRECTORY OF YOUR LOCAL CLOUD CLIENT -/home/USER/CLOUD From c9f9d96955fd7b476d310a0d749c966ece3e5e99 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Fri, 8 Apr 2022 15:09:21 +0200 Subject: [PATCH 36/54] Revise checking slashs --- cloud-backup.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 83d0f1a..1b53f75 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -1,9 +1,8 @@ # Cloud Backup v.1.1 - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html -# Please define your data with the tool "cloud-backup-settings.py" at first. +# Prepare the backdata.txt and put it in the same directory like this script. # Then you can backup your calendars and adressbook directly from the cloud. -# If you want to store your data-directory also, the desktop-client has to be installed. import configparser import requests @@ -12,8 +11,10 @@ import shutil import zipfile +# ADD NORMPATH AND OPPORTUNITY FOR TWO SLASH VARIANTS def checkSlash(check): - if check[-1] != "/": + last = check[-1] + if last != "/" and last != "\u005C": check = check + "/" return check @@ -37,7 +38,9 @@ def checkSlash(check): for key in config["GENERAL"]: val.append(config["GENERAL"][key]) path = checkSlash(val[1]) +path = os.path.normpath(path, 1) backupdir = path + folderdate + "/" +backupdir = os.path.normpath(backupdir, 1) print ("Backup directory is " + backupdir) maintain = val[2] print (maintain + " older subdirectories will be stored\n") @@ -48,7 +51,8 @@ def checkSlash(check): url = checkSlash(val[8]) calendarlist = val[9].replace('\n', "").split(",") clientfolder = val[11] -clientfolder = clientfolder.replace('\n', "") +#clientfolder = clientfolder.replace('\n', "") +clientfolder = os.path.normpath(clientfolder,0) # Check and create storage directory if not os.path.exists(path): From bf34c58dd9cdcdb859e20ae9b76fb480c0a39069 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Fri, 8 Apr 2022 15:19:34 +0200 Subject: [PATCH 37/54] Check slash for client folder --- cloud-backup.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 1b53f75..7e0c888 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -11,11 +11,16 @@ import shutil import zipfile -# ADD NORMPATH AND OPPORTUNITY FOR TWO SLASH VARIANTS -def checkSlash(check): +def checkSlash(check, variant): last = check[-1] if last != "/" and last != "\u005C": - check = check + "/" + if variant == 0: + return check + else: + check = check + "/" + return check + elif variant == 0: + check = check[:-1] return check print ("Cloud Backup v.1.1filedev") @@ -51,8 +56,7 @@ def checkSlash(check): url = checkSlash(val[8]) calendarlist = val[9].replace('\n', "").split(",") clientfolder = val[11] -#clientfolder = clientfolder.replace('\n', "") -clientfolder = os.path.normpath(clientfolder,0) +clientfolder = os.path.normpath(clientfolder, 0) # Check and create storage directory if not os.path.exists(path): From a0df801828bfa06aa926af0206b41ad956758315 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Fri, 8 Apr 2022 15:25:36 +0200 Subject: [PATCH 38/54] Fix wrong variable positions --- cloud-backup.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 7e0c888..97d9b91 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -42,21 +42,21 @@ def checkSlash(check, variant): x = 0 for key in config["GENERAL"]: val.append(config["GENERAL"][key]) -path = checkSlash(val[1]) -path = os.path.normpath(path, 1) +path = checkSlash(val[1], 1) +path = os.path.normpath(path) backupdir = path + folderdate + "/" -backupdir = os.path.normpath(backupdir, 1) +backupdir = os.path.normpath(backupdir) print ("Backup directory is " + backupdir) maintain = val[2] print (maintain + " older subdirectories will be stored\n") maintain = int(maintain) user = val[3] passwd = val[4] -urlvcf = checkSlash(val[6]) -url = checkSlash(val[8]) +urlvcf = checkSlash(val[6], 1) +url = checkSlash(val[8], 1) calendarlist = val[9].replace('\n', "").split(",") -clientfolder = val[11] -clientfolder = os.path.normpath(clientfolder, 0) +clientfolder = checkSlash(val[11], 0) +clientfolder = os.path.normpath(clientfolder) # Check and create storage directory if not os.path.exists(path): From 5ecd0733ce6e9eac0ba29a0032c6888edb22d5bc Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Fri, 8 Apr 2022 19:27:42 +0200 Subject: [PATCH 39/54] Revise checking slashs; solve adressbook conflicts --- cloud-backup.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 97d9b91..1a513bf 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -1,4 +1,4 @@ -# Cloud Backup v.1.1 - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ +# Cloud Backup v.1.1filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html # Prepare the backdata.txt and put it in the same directory like this script. @@ -12,15 +12,12 @@ import zipfile def checkSlash(check, variant): - last = check[-1] - if last != "/" and last != "\u005C": - if variant == 0: - return check - else: - check = check + "/" - return check - elif variant == 0: - check = check[:-1] + if variant == 1: + check = os.path.normpath(check) + if not check.endswith(os.path.sep): + check += os.path.sep + elif variant == 2 and check[-1] != "/": + check = check + "/" return check print ("Cloud Backup v.1.1filedev") @@ -43,20 +40,19 @@ def checkSlash(check, variant): for key in config["GENERAL"]: val.append(config["GENERAL"][key]) path = checkSlash(val[1], 1) -path = os.path.normpath(path) -backupdir = path + folderdate + "/" -backupdir = os.path.normpath(backupdir) +backupdir = path + folderdate +backupdir = checkSlash(backupdir, 1) print ("Backup directory is " + backupdir) maintain = val[2] print (maintain + " older subdirectories will be stored\n") maintain = int(maintain) user = val[3] passwd = val[4] -urlvcf = checkSlash(val[6], 1) -url = checkSlash(val[8], 1) +urlvcf = checkSlash(val[6], 2) +urlvcf = urlvcf + "?export" +url = checkSlash(val[8], 2) calendarlist = val[9].replace('\n', "").split(",") -clientfolder = checkSlash(val[11], 0) -clientfolder = os.path.normpath(clientfolder) +clientfolder = checkSlash(val[11], 1) # Check and create storage directory if not os.path.exists(path): From e21e77b980f9ddc70579478def156d210de4bc62 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Fri, 8 Apr 2022 19:48:16 +0200 Subject: [PATCH 40/54] Revise printing folders for cleaning --- cloud-backup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 1a513bf..26ed583 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -36,7 +36,6 @@ def checkSlash(check, variant): data = data + "/data.ini" config.read (data) val = [] -x = 0 for key in config["GENERAL"]: val.append(config["GENERAL"][key]) path = checkSlash(val[1], 1) @@ -59,14 +58,18 @@ def checkSlash(check, variant): os.makedirs(path) # Check older versions -print ("\nCheck older versions for cleaning...") +print ("Check older versions for cleaning...") if os.path.exists(backupdir): maintain = maintain + 1 def sorted_ls(path): mtime = lambda f: os.stat(os.path.join(path, f)).st_ctime return list(sorted(os.listdir(path), key = mtime)) del_list = sorted_ls(path)[0:(len(sorted_ls(path)) - maintain)] -print (del_list) +printDel = ",".join(del_list) +if printDel == "": + print ("none") +else: + print (printDel) # Check and create todays subfolder if not os.path.exists(backupdir): From 10422b29d08a2c0912b79562d38020492101cc26 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Fri, 8 Apr 2022 22:09:30 +0200 Subject: [PATCH 41/54] Make formulation changes; add variables --- cloud-backup.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 26ed583..077b9e5 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -22,15 +22,13 @@ def checkSlash(check, variant): print ("Cloud Backup v.1.1filedev") print ("Feel free to visit trmsc1.wordpress.com") -print ("\nCheck data...") -# Check date +# Check data and settings +print ("\nPreparing backup...") starttime = datetime.datetime.now() folderdate = datetime.datetime.now().strftime("%Y-%m-%d") filedate = folderdate + datetime.datetime.now().strftime("-%H-%M") -print ("Time is " + filedate) - -# Check data +print ("Time: " + filedate) config = configparser.ConfigParser() data = os.path.dirname(__file__) data = data + "/data.ini" @@ -41,16 +39,22 @@ def checkSlash(check, variant): path = checkSlash(val[1], 1) backupdir = path + folderdate backupdir = checkSlash(backupdir, 1) -print ("Backup directory is " + backupdir) +print ("Backup directory: " + backupdir) maintain = val[2] -print (maintain + " older subdirectories will be stored\n") +print ("Number of older stored subdirectories: " + maintain) maintain = int(maintain) user = val[3] passwd = val[4] +card = val[5] +print ("Adressbook backup: " + card) urlvcf = checkSlash(val[6], 2) urlvcf = urlvcf + "?export" +calendar = val[7] +print ("Calendar backup: " + calendar) url = checkSlash(val[8], 2) calendarlist = val[9].replace('\n', "").split(",") +clouddata = val[10] +print ("Data backup: " + clouddata) clientfolder = checkSlash(val[11], 1) # Check and create storage directory @@ -58,7 +62,7 @@ def checkSlash(check, variant): os.makedirs(path) # Check older versions -print ("Check older versions for cleaning...") +print ("\nCheck older versions for cleaning...") if os.path.exists(backupdir): maintain = maintain + 1 def sorted_ls(path): From 59fa44485cf22b2f491cc249907bb7e83f10281a Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Fri, 8 Apr 2022 23:28:21 +0200 Subject: [PATCH 42/54] Start translating to functions --- cloud-backup.py | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 077b9e5..07bc9de 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -11,6 +11,16 @@ import shutil import zipfile +def getData(): + config = configparser.ConfigParser() + data = os.path.dirname(__file__) + data = data + "/data.ini" + config.read (data) + val = [] + for key in config["GENERAL"]: + val.append(config["GENERAL"][key]) + return val + def checkSlash(check, variant): if variant == 1: check = os.path.normpath(check) @@ -23,19 +33,18 @@ def checkSlash(check, variant): print ("Cloud Backup v.1.1filedev") print ("Feel free to visit trmsc1.wordpress.com") -# Check data and settings +val = getData() + +# Make Functions: +# PREPARE +# START (CARD, CALENDAR, DATA) +# FINISH + print ("\nPreparing backup...") starttime = datetime.datetime.now() folderdate = datetime.datetime.now().strftime("%Y-%m-%d") filedate = folderdate + datetime.datetime.now().strftime("-%H-%M") print ("Time: " + filedate) -config = configparser.ConfigParser() -data = os.path.dirname(__file__) -data = data + "/data.ini" -config.read (data) -val = [] -for key in config["GENERAL"]: - val.append(config["GENERAL"][key]) path = checkSlash(val[1], 1) backupdir = path + folderdate backupdir = checkSlash(backupdir, 1) @@ -57,11 +66,10 @@ def checkSlash(check, variant): print ("Data backup: " + clouddata) clientfolder = checkSlash(val[11], 1) -# Check and create storage directory +# PREPARE if not os.path.exists(path): os.makedirs(path) - -# Check older versions + print ("\nCheck older versions for cleaning...") if os.path.exists(backupdir): maintain = maintain + 1 @@ -75,14 +83,13 @@ def sorted_ls(path): else: print (printDel) -# Check and create todays subfolder if not os.path.exists(backupdir): os.makedirs(backupdir) -# Start backup progress +# START print ("\nStart backup progress...") -# Calendar download +# CALENDAR for i in calendarlist: filename = backupdir + filedate + "-" + i + ".ics" print ("Downloading " + filename) @@ -92,14 +99,14 @@ def sorted_ls(path): with open(filename, 'wb') as k: k.write(r.content) -# Adressbook download +# ADRESSBOOK filename = backupdir + filedate + "-adressbook.vcf" print ("Downloading " + filename) r = requests.get(urlvcf, auth=(user, passwd),allow_redirects=True) with open(filename, 'wb') as a: a.write(r.content) -# Copy and zip local client files +# DATA clientfile = backupdir + filedate + "-localfiles.zip" countfiles = 0 print ("\nCreate " + clientfile + " and add files...") @@ -112,7 +119,7 @@ def sorted_ls(path): countfiles +=1 print (str(countfiles) + " files were added to " + clientfile) -# Remove older versions +# FINISH print ("\nClean older versions...") if del_list == []: print ("none") @@ -120,7 +127,6 @@ def sorted_ls(path): print ("Removing " + path + dfile) shutil.rmtree(path + dfile) -# Finish endtime = datetime.datetime.now() duration = endtime - starttime print ("\nBackup finished after a duration of " + str(duration)) From 448e5df2e1d91c6e901e18a54c59a4fa7e87f765 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:15:45 +0200 Subject: [PATCH 43/54] Subdivide code in functions --- cloud-backup.py | 114 +++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 55 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 07bc9de..5c9c749 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -16,11 +16,16 @@ def getData(): data = os.path.dirname(__file__) data = data + "/data.ini" config.read (data) - val = [] for key in config["GENERAL"]: val.append(config["GENERAL"][key]) return val +def stampTime(): + starttime = datetime.datetime.now() + folderdate = datetime.datetime.now().strftime("%Y-%m-%d") + filedate = folderdate + datetime.datetime.now().strftime("-%H-%M") + return starttime, folderdate, filedate + def checkSlash(check, variant): if variant == 1: check = os.path.normpath(check) @@ -30,66 +35,62 @@ def checkSlash(check, variant): check = check + "/" return check -print ("Cloud Backup v.1.1filedev") -print ("Feel free to visit trmsc1.wordpress.com") +def prepareOverarching(): + path = checkSlash(val[1], 1) + backupdir = path + folderdate + backupdir = checkSlash(backupdir, 1) + print ("Backup directory: " + backupdir) + maintain = val[2] + print ("Number of older stored subdirectories: " + maintain) + maintain = int(maintain) + user = val[3] + passwd = val[4] + return path, backupdir, maintain, user, passwd -val = getData() +def backupCheck(): + card = val[5] + print ("Adressbook backup: " + card) + calendar = val[7] + print ("Calendar backup: " + calendar) + clouddata = val[10] + print ("Data backup: " + clouddata) + if not os.path.exists(path): + os.makedirs(path) + return -# Make Functions: -# PREPARE -# START (CARD, CALENDAR, DATA) -# FINISH +def prepareFolders(maintain): + print ("\nCheck older versions for cleaning...") + if os.path.exists(backupdir): + maintain = maintain + 1 + def makeList(path): + mtime = lambda f: os.stat(os.path.join(path, f)).st_ctime + return list(sorted(os.listdir(path), key = mtime)) + removeDir = makeList(path)[0:(len(makeList(path)) - maintain)] + printDir = ",".join(removeDir) + if printDir == "": + print ("none") + else: + print (printDir) + if not os.path.exists(backupdir): + os.makedirs(backupdir) + return removeDir +# MAIN ------------------------------------------------ +print ("Cloud Backup v.1.1filedev") +print ("Feel free to visit trmsc1.wordpress.com") +val = [] +val = getData() print ("\nPreparing backup...") -starttime = datetime.datetime.now() -folderdate = datetime.datetime.now().strftime("%Y-%m-%d") -filedate = folderdate + datetime.datetime.now().strftime("-%H-%M") +starttime, folderdate, filedate = stampTime() print ("Time: " + filedate) -path = checkSlash(val[1], 1) -backupdir = path + folderdate -backupdir = checkSlash(backupdir, 1) -print ("Backup directory: " + backupdir) -maintain = val[2] -print ("Number of older stored subdirectories: " + maintain) -maintain = int(maintain) -user = val[3] -passwd = val[4] -card = val[5] -print ("Adressbook backup: " + card) -urlvcf = checkSlash(val[6], 2) -urlvcf = urlvcf + "?export" -calendar = val[7] -print ("Calendar backup: " + calendar) -url = checkSlash(val[8], 2) -calendarlist = val[9].replace('\n', "").split(",") -clouddata = val[10] -print ("Data backup: " + clouddata) -clientfolder = checkSlash(val[11], 1) - -# PREPARE -if not os.path.exists(path): - os.makedirs(path) - -print ("\nCheck older versions for cleaning...") -if os.path.exists(backupdir): - maintain = maintain + 1 -def sorted_ls(path): - mtime = lambda f: os.stat(os.path.join(path, f)).st_ctime - return list(sorted(os.listdir(path), key = mtime)) -del_list = sorted_ls(path)[0:(len(sorted_ls(path)) - maintain)] -printDel = ",".join(del_list) -if printDel == "": - print ("none") -else: - print (printDel) - -if not os.path.exists(backupdir): - os.makedirs(backupdir) - -# START +path, backupdir, maintain, user, passwd = prepareOverarching() +backupCheck() +removeDir = prepareFolders(maintain) print ("\nStart backup progress...") # CALENDAR +url = checkSlash(val[8], 2) +calendarlist = val[9].replace('\n', "").split(",") for i in calendarlist: filename = backupdir + filedate + "-" + i + ".ics" print ("Downloading " + filename) @@ -100,6 +101,8 @@ def sorted_ls(path): k.write(r.content) # ADRESSBOOK +urlvcf = checkSlash(val[6], 2) +urlvcf = urlvcf + "?export" filename = backupdir + filedate + "-adressbook.vcf" print ("Downloading " + filename) r = requests.get(urlvcf, auth=(user, passwd),allow_redirects=True) @@ -107,6 +110,7 @@ def sorted_ls(path): a.write(r.content) # DATA +clientfolder = checkSlash(val[11], 1) clientfile = backupdir + filedate + "-localfiles.zip" countfiles = 0 print ("\nCreate " + clientfile + " and add files...") @@ -121,9 +125,9 @@ def sorted_ls(path): # FINISH print ("\nClean older versions...") -if del_list == []: +if removeDir == []: print ("none") -for dfile in del_list: +for dfile in removeDir: print ("Removing " + path + dfile) shutil.rmtree(path + dfile) From ebbe51daea5fa4b1b37c1f0ba6a091b342a4dfbf Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:30:22 +0200 Subject: [PATCH 44/54] Complete function structure --- cloud-backup.py | 109 ++++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 49 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index 5c9c749..b6a9fcd 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -11,6 +11,8 @@ import shutil import zipfile +version = "v.1.1filedev" + def getData(): config = configparser.ConfigParser() data = os.path.dirname(__file__) @@ -75,8 +77,57 @@ def makeList(path): os.makedirs(backupdir) return removeDir -# MAIN ------------------------------------------------ -print ("Cloud Backup v.1.1filedev") +def storeAdressbook(): + urlvcf = checkSlash(val[6], 2) + urlvcf = urlvcf + "?export" + filename = backupdir + filedate + "-adressbook.vcf" + print ("Downloading " + filename) + r = requests.get(urlvcf, auth=(user, passwd),allow_redirects=True) + with open(filename, 'wb') as a: + a.write(r.content) + return + +def storeCalendar(): + url = checkSlash(val[8], 2) + calendarlist = val[9].replace('\n', "").split(",") + for i in calendarlist: + filename = backupdir + filedate + "-" + i + ".ics" + print ("Downloading " + filename) + calurl = url + i + "/?export" + calurl = calurl.replace('\n', "") + r = requests.get(calurl, auth = (user, passwd), allow_redirects = True) + with open(filename, 'wb') as k: + k.write(r.content) + return + +def storeData(): + clientfolder = checkSlash(val[11], 1) + clientfile = backupdir + filedate + "-localfiles.zip" + countfiles = 0 + print ("\nCreate " + clientfile + " and add files...") + with zipfile.ZipFile(clientfile, 'w', zipfile.ZIP_DEFLATED) as target: + for root, dirs, files in os.walk(clientfolder): + for file in files: + add = os.path.join(root, file) + target.write(add) + print("Add " + add) + countfiles +=1 + print (str(countfiles) + " files were added to " + clientfile) + return + +def finishBackup(): + print ("\nClean older versions...") + if removeDir == []: + print ("none") + for dfile in removeDir: + print ("Removing " + path + dfile) + shutil.rmtree(path + dfile) + endtime = datetime.datetime.now() + duration = endtime - starttime + print ("\nBackup finished after a duration of " + str(duration)) + return + +print ("Cloud Backup " + version) print ("Feel free to visit trmsc1.wordpress.com") val = [] val = getData() @@ -87,50 +138,10 @@ def makeList(path): backupCheck() removeDir = prepareFolders(maintain) print ("\nStart backup progress...") - -# CALENDAR -url = checkSlash(val[8], 2) -calendarlist = val[9].replace('\n', "").split(",") -for i in calendarlist: - filename = backupdir + filedate + "-" + i + ".ics" - print ("Downloading " + filename) - calurl = url + i + "/?export" - calurl = calurl.replace('\n', "") - r = requests.get(calurl, auth = (user, passwd), allow_redirects = True) - with open(filename, 'wb') as k: - k.write(r.content) - -# ADRESSBOOK -urlvcf = checkSlash(val[6], 2) -urlvcf = urlvcf + "?export" -filename = backupdir + filedate + "-adressbook.vcf" -print ("Downloading " + filename) -r = requests.get(urlvcf, auth=(user, passwd),allow_redirects=True) -with open(filename, 'wb') as a: - a.write(r.content) - -# DATA -clientfolder = checkSlash(val[11], 1) -clientfile = backupdir + filedate + "-localfiles.zip" -countfiles = 0 -print ("\nCreate " + clientfile + " and add files...") -with zipfile.ZipFile(clientfile, 'w', zipfile.ZIP_DEFLATED) as target: - for root, dirs, files in os.walk(clientfolder): - for file in files: - add = os.path.join(root, file) - target.write(add) - print("Add " + add) - countfiles +=1 -print (str(countfiles) + " files were added to " + clientfile) - -# FINISH -print ("\nClean older versions...") -if removeDir == []: - print ("none") -for dfile in removeDir: - print ("Removing " + path + dfile) - shutil.rmtree(path + dfile) - -endtime = datetime.datetime.now() -duration = endtime - starttime -print ("\nBackup finished after a duration of " + str(duration)) +if val[5] == "yes": + storeAdressbook() +if val[7] == "yes": + storeCalendar() +if val[10] == "yes": + storeData() +finishBackup() From 53d8a4c376f4a7dca692615585f525205b52e25d Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 00:58:05 +0200 Subject: [PATCH 45/54] Adjust informations for new version --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 477d6fa..7bddb8d 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,17 @@ Further a big thanks to [Cermit](https://twitter.com/Cermit3273?s=20&t=quwG6m5sD --- _Please notice: This is my first python script. I have coded it attentive and I hope that everything works well without any guarantee of it._ -_Until now the script is tested with [Nextcloud](https://nextcloud.com/)._ +_Until now the script is tested with [Nextcloud](https://nextcloud.com/) under [Windows](https://www.microsoft.com/de-de/windows/) and some Linux distributions like [Kubuntu](https://kubuntu.org/) and [Raspberry Pi OS](https://www.raspberrypi.com/software/)._ --- ### How to: -- Please put the following files in the same directory. 📁 - - cloud-backup.py - - cloud-backup-data.txt +- Download and put the files from the repository in the same directory. 📁 -- Add your values to the data-file. 🖊 +- Run "cloud-backup-settings.py" to make the settings. 🖊 -- Backup your calendars an adressbook by starting the script. 💾 +- Backup your calendars, adressbook and local cloud data by starting the script "cloud-backup.py". 💾 - Finished! 🎉 @@ -32,8 +30,8 @@ ___Note: You can use the script manually or control it with a cronjob!___ ### Roadmap: - Making executable package files for linux and windows -- Backup the data-directory from the cloud -- Integrate configparser module to make settings more comfortable +- Possibility to make backups from different clouds +- Implement official feature to make backups from local sources --- @@ -49,6 +47,11 @@ v.1.0.1 v.1.1 - Autoremove older subdirectories by setting the number individually +v.1.2 +- Store data directory from by having installed the client +- Tool for making all the settings +- Code cleaning + --- From b721059b6ba4207f8376e3568b667af8ac69735e Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 01:03:06 +0200 Subject: [PATCH 46/54] Adjust version --- cloud-backup-settings.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 1fe5918..1477d3a 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Cloud Backup v.1.1.filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ +# Cloud Backup - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html import configparser @@ -10,6 +10,8 @@ import getpass from pickle import TRUE +version = "v.1.2" + def initConfig(): val = readData() encr = encryptPwd(val) @@ -201,6 +203,6 @@ def openCallist (): return listcontent config = configparser.ConfigParser() -print ("\nWelcome to cloud-backup configuration v.1.1") +print ("\nWelcome to cloud-backup configuration " + version) print ("Feel free to visit trmsc1.wordpress.com") initConfig() From 1693cbdb2a3b5081e0d3b7fa0e6cdf7652135a00 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 01:03:46 +0200 Subject: [PATCH 47/54] Adjust version --- cloud-backup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud-backup.py b/cloud-backup.py index b6a9fcd..d007171 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -1,4 +1,4 @@ -# Cloud Backup v.1.1filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ +# Cloud Backup - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html # Prepare the backdata.txt and put it in the same directory like this script. @@ -11,7 +11,7 @@ import shutil import zipfile -version = "v.1.1filedev" +version = "v.1.2" def getData(): config = configparser.ConfigParser() From 15d918f76f581c0d30b2a5188f9c648ae906c841 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 13:48:58 +0200 Subject: [PATCH 48/54] Update changelog, description and how-to --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7bddb8d..27a2adf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Cloud Backup -## Backup your calendars and adressbook directly from the cloud! +## Backup your calendars, adressbook and files* directly from the cloud! Thanks to [Tiktaktux-Wiki](https://www.tiktaktux.de/doku.php?id=linux:caldav_und_carddav_backup_erstellen) and [Henry Koch](https://www.henrykoch.de/de/python-loeschen-der-aeltesten-files-in-einem-verzeichnis-nur-die-neuesten-x-bleiben-zurueck) for important bases. ✨ @@ -15,15 +15,17 @@ _Until now the script is tested with [Nextcloud](https://nextcloud.com/) under [ ### How to: -- Download and put the files from the repository in the same directory. 📁 +- Download the repository and put all files in the same directory. 📁 -- Run "cloud-backup-settings.py" to make the settings. 🖊 +- Run __cloud-backup-settings.py__ to config your backups. ⚙ -- Backup your calendars, adressbook and local cloud data by starting the script "cloud-backup.py". 💾 +- Backup your calendars, adressbook and files* by starting the script __cloud-backup.py__. 💾 - Finished! 🎉 ___Note: You can use the script manually or control it with a cronjob!___ + +\* _Backuping files is a new feature in v.1.2: For this part the client of your cloud has to be installed. The tool creates a zip file with the specified local data in it. For backuping your calendars and adressbook the client isn't needed._ --- @@ -50,6 +52,8 @@ v.1.1 v.1.2 - Store data directory from by having installed the client - Tool for making all the settings +- Activate or deactivate single backup parts +- Work with relative paths to avoid relation errors - Code cleaning --- From 7b2272b6c20a411bd1716d233e768764202e78ff Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 13:51:53 +0200 Subject: [PATCH 49/54] Revise changelog --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27a2adf..3cf872e 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,8 @@ v.1.1 - Autoremove older subdirectories by setting the number individually v.1.2 -- Store data directory from by having installed the client -- Tool for making all the settings +- Provide a new tool for making all the settings +- Store files from your cloud by having installed the client - Activate or deactivate single backup parts - Work with relative paths to avoid relation errors - Code cleaning From 3d0f55c3fa804e1856aacf396f289e1dacbbfec9 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 14:43:12 +0200 Subject: [PATCH 50/54] Add download link to the latest release --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cf872e..09418fb 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ _Until now the script is tested with [Nextcloud](https://nextcloud.com/) under [ ### How to: -- Download the repository and put all files in the same directory. 📁 +- [Download the latest version](https://github.com/TRMSC/cloud-backup/releases) and unzip all files in one directory. 📁 - Run __cloud-backup-settings.py__ to config your backups. ⚙ From a9aa5471a5a8c8cea7132b0ab800cb3eaf628b8f Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 15:55:58 +0200 Subject: [PATCH 51/54] Add shebang --- cloud-backup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cloud-backup.py b/cloud-backup.py index d007171..de1dbe2 100644 --- a/cloud-backup.py +++ b/cloud-backup.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # Cloud Backup - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html From fbc6752285f34ca046485468bdfe05e152ee4cb2 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 15:57:49 +0200 Subject: [PATCH 52/54] Change shebang to python 3 --- cloud-backup-settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index 1477d3a..f6e5d47 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Cloud Backup - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html @@ -15,7 +15,7 @@ def initConfig(): val = readData() encr = encryptPwd(val) - print ("\n- - - - - - - - - - - - - - - - -") + print ("\n- - - - - - - - - - - - - - - - -\n") print ("Last modified: " + val[0] + "\n") print (" 1 - GENERAL - Change backup directory (" + val[1] + ")") print (" 2 - GENERAL - Number of stored backups (" + val[2] + ")") From ec512974280186d3f7903a660f35b32a4742820b Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 17:16:04 +0200 Subject: [PATCH 53/54] Remove space --- data.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data.ini b/data.ini index d68a4cc..0379071 100644 --- a/data.ini +++ b/data.ini @@ -8,6 +8,6 @@ cardAct = no card = YOURURL/remote.php/dav/adressbooks/users/USERNAME/contacts/ calAct = no cal = YOURURL/remote.php/dav/calendars/USERNAME/ -callist = CALENDARNAME1, CALENDARNAME2 +callist = CALENDARNAME1,CALENDARNAME2 clientAct = no client = /home/USER/CLOUD From 7a544db6c4ca3246270ead23851fb4788bb33fd0 Mon Sep 17 00:00:00 2001 From: TRMSC <86586942+TRMSC@users.noreply.github.com> Date: Sat, 9 Apr 2022 19:31:52 +0200 Subject: [PATCH 54/54] Solve problem having an empty calendarlist --- cloud-backup-settings.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cloud-backup-settings.py b/cloud-backup-settings.py index f6e5d47..d341d20 100644 --- a/cloud-backup-settings.py +++ b/cloud-backup-settings.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python -# Cloud Backup - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ +# Cloud Backup v.1.1.filedev - Copyright (C) 2022, TRMSC - https://trmsc1.wordpress.com/ # GNU General Public Licence 3.0 - http://www.gnu.de/documents/gpl-3.0.en.html import configparser @@ -15,7 +15,7 @@ def initConfig(): val = readData() encr = encryptPwd(val) - print ("\n- - - - - - - - - - - - - - - - -\n") + print ("\n- - - - - - - - - - - - - - - - -") print ("Last modified: " + val[0] + "\n") print (" 1 - GENERAL - Change backup directory (" + val[1] + ")") print (" 2 - GENERAL - Number of stored backups (" + val[2] + ")") @@ -164,6 +164,7 @@ def openCallist (): calendarlist = val[9].replace('\n', "").split(",") listcontent = val[9] choice = "x" + empty = 0 while choice != "": items = len(calendarlist) itemsDisp = items + 1 @@ -171,6 +172,7 @@ def openCallist (): print("") if position == items: print ("No calendarlists...") + empty = 1 else: while position < items: posDisp = position + 1 @@ -191,7 +193,11 @@ def openCallist (): elif isInt and int(choice) >= itemsDisp: print ("CALENDAR DOES NOT EXIST.") elif choice != "": - listcontent = listcontent + "," + choice + if empty == 1: + listcontent = choice + empty = 0 + else: + listcontent = listcontent + "," + choice calendarlist = listcontent.replace('\n', "").split(",") print (listcontent) print ("\nOld version: " + val[9])