Simple backup folder using zip
#import modules
import os
import os.path
import datetime
#ask backup name and source folder
print("Enter backup name (without date) :")
b_name=input()
print("Enter source backup folder :")
s_backup=input()
#Checking if source folder exist or not
filecheck=os.path.exists(s_backup)
#generate date for backup identification
x=datetime.date.today()
y=x.strftime("%d%b%Y")
#if source folder found do backup
if filecheck == True:
os.system("zip -r "+b_name+y+".zip "+s_backup)
result=os.listdir(os.getcwd())
print("'\n\n'Your list directory : ")
print(result)
else:
print("Your source backup folder not found")
Simple backup folder using zip (with function and looping)
#impor modules
import os
import os.path
import datetime
#define function
def backupfunction():
#ask for backup and source folder name
name = input("Backup name : ")
source = input("Backup source : ")
check=os.path.exists(source)
x=datetime.datetime.today()
y=x.strftime("%d%b%Y")
if check == True:
os.system("zip -r "+name+y+".zip "+source)
result=os.listdir(os.getcwd())
print("'\n\n'Your list directory : ")
print(result)
else:
backupfunction()
backupfunction()