From 13bad49747a2de6b3b116d5890dd3a453677acc2 Mon Sep 17 00:00:00 2001 From: xpamych Date: Thu, 1 Jun 2023 19:42:44 +0300 Subject: [PATCH] 1 --- hlna.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hlna.py b/hlna.py index ea38cdf..0404d62 100755 --- a/hlna.py +++ b/hlna.py @@ -68,7 +68,7 @@ def hlna(): @hlna.command(help='Восстановление бэкапов серверов в ') @click.argument('g', nargs=1) @click.option('-d',required=True , help="Путь до zip архива") -def restore(g,d): +def restore(g, d): directory_to_extract_to = "*******" "Получение пути к файлам внутри архива, может понадобиться при раскидывании по местам" "===================================================================================" @@ -101,20 +101,20 @@ def backup(g): source = [f"{dir_config}"] backup_path = input("Введите конечный путь для бэкапа, по умолчанию ******") if not backup_path: - backup_path = "/home/a11" + backup_path = f"{dir_server_ark}Backups" - today= backup_path + os.sep + time.strftime('%Y_%m_%d') - target = f"{backup_path}/" + g + "_backup-"+ time.strftime('%H_%M_%S') + '.zip' + today = backup_path + os.sep + time.strftime('%Y_%m_%d') + target = f"{backup_path}/" + g + "_backup-" + time.strftime('%H_%M_%S') + '.zip' create_dir(backup_path) with zipfile.ZipFile(target, 'w', zipfile.ZIP_DEFLATED, True) as myzip: for source_folder in source: - for root,dirs,files in os.walk(source_folder): + for root, dirs, files in os.walk(source_folder): for file in files: path = os.path.join(root, file) myzip.write(path) - print(path, colorama.Fore.GREEN + "- перемещен" + colorama.Style.RESET_ALL ) + print(path, colorama.Fore.GREEN + "- перемещен" + colorama.Style.RESET_ALL) - print(colorama.Fore.GREEN + f"Конфиги сохранены в {target}" + colorama.Style.RESET_ALL ) + print(colorama.Fore.GREEN + f"Конфиги сохранены в {target}" + colorama.Style.RESET_ALL) elif g == "7days": pass else: @@ -994,6 +994,7 @@ def zero(x=""): """Потом пригодится (нет)""" return "" + if not os.path.exists(dir_config + "config"): dir_server = path_server() else: