1
This commit is contained in:
parent
30c2024c1b
commit
13bad49747
15
hlna.py
15
hlna.py
@ -68,7 +68,7 @@ def hlna():
|
|||||||
@hlna.command(help='Восстановление бэкапов серверов в <hlna restore ark>')
|
@hlna.command(help='Восстановление бэкапов серверов в <hlna restore ark>')
|
||||||
@click.argument('g', nargs=1)
|
@click.argument('g', nargs=1)
|
||||||
@click.option('-d',required=True , help="Путь до zip архива")
|
@click.option('-d',required=True , help="Путь до zip архива")
|
||||||
def restore(g,d):
|
def restore(g, d):
|
||||||
directory_to_extract_to = "*******"
|
directory_to_extract_to = "*******"
|
||||||
"Получение пути к файлам внутри архива, может понадобиться при раскидывании по местам"
|
"Получение пути к файлам внутри архива, может понадобиться при раскидывании по местам"
|
||||||
"==================================================================================="
|
"==================================================================================="
|
||||||
@ -101,20 +101,20 @@ def backup(g):
|
|||||||
source = [f"{dir_config}"]
|
source = [f"{dir_config}"]
|
||||||
backup_path = input("Введите конечный путь для бэкапа, по умолчанию ******")
|
backup_path = input("Введите конечный путь для бэкапа, по умолчанию ******")
|
||||||
if not backup_path:
|
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')
|
today = backup_path + os.sep + time.strftime('%Y_%m_%d')
|
||||||
target = f"{backup_path}/" + g + "_backup-"+ time.strftime('%H_%M_%S') + '.zip'
|
target = f"{backup_path}/" + g + "_backup-" + time.strftime('%H_%M_%S') + '.zip'
|
||||||
create_dir(backup_path)
|
create_dir(backup_path)
|
||||||
with zipfile.ZipFile(target, 'w', zipfile.ZIP_DEFLATED, True) as myzip:
|
with zipfile.ZipFile(target, 'w', zipfile.ZIP_DEFLATED, True) as myzip:
|
||||||
for source_folder in source:
|
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:
|
for file in files:
|
||||||
path = os.path.join(root, file)
|
path = os.path.join(root, file)
|
||||||
myzip.write(path)
|
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":
|
elif g == "7days":
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -994,6 +994,7 @@ def zero(x=""):
|
|||||||
"""Потом пригодится (нет)"""
|
"""Потом пригодится (нет)"""
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
if not os.path.exists(dir_config + "config"):
|
if not os.path.exists(dir_config + "config"):
|
||||||
dir_server = path_server()
|
dir_server = path_server()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user