-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
import os | ||
import shutil | ||
from datetime import datetime | ||
from logger import log, RED, YELLOW, GREEN, NC | ||
from logger import log, get_translation, RED, YELLOW, GREEN, NC | ||
import sys | ||
|
||
def backup_efi(efi_dir): | ||
"""Cria backup da EFI.""" | ||
efi_backup_dir = os.path.join(efi_dir, f"EFI-Backup-{datetime.now().strftime('%Y%m%d%H%M%S')}") | ||
log(f"{YELLOW}Criando backup em {efi_backup_dir}...{NC}") | ||
"""Cria backup da EFI, perguntando ao usuário se ele deseja prosseguir.""" | ||
|
||
def confirm_backup(): | ||
"""Pergunta ao usuário se ele deseja fazer um backup da EFI.""" | ||
while True: | ||
choice = input(f"{get_translation('confirm_backup')} (y/n): ").lower() | ||
if choice in ['y', 'yes', 's', 'sim']: | ||
return True | ||
elif choice in ['n', 'no']: | ||
return False | ||
else: | ||
log(f"{RED}{get_translation('invalid_option')}{NC}") | ||
|
||
if not confirm_backup(): | ||
log(f"{YELLOW}Backup cancelado pelo usuário.{NC}") | ||
return # Sai da função se o usuário não quiser fazer backup | ||
|
||
backup_dir = os.path.join(efi_dir, f"EFI-Backup-{datetime.now().strftime('%Y%m%d%H%M%S')}") | ||
log(f"{YELLOW}Criando backup em {backup_dir}...{NC}") | ||
try: | ||
# Usando o caminho completo da EFI | ||
shutil.copytree(os.path.join(efi_dir, "EFI"), efi_backup_dir) | ||
shutil.copytree(os.path.join(efi_dir, "EFI"), backup_dir) | ||
log(f"{GREEN}Backup criado com sucesso.{NC}") | ||
except Exception as e: | ||
log(f"{RED}Erro ao criar o backup: {e}{NC}") | ||
sys.exit(1) | ||
sys.exit(1) |