diff options
author | crupest <crupest@outlook.com> | 2023-12-11 15:02:08 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2024-03-25 22:25:21 +0800 |
commit | 77c5f0d98f8318c8ec99fee64591b0701e270224 (patch) | |
tree | 56d7f83e4d4d736890d8d3999379a459b5d96ccf /tool/modules/backup.py | |
parent | 52566293e75055513d397bf3ad64af969cd1f185 (diff) | |
download | crupest-77c5f0d98f8318c8ec99fee64591b0701e270224.tar.gz crupest-77c5f0d98f8318c8ec99fee64591b0701e270224.tar.bz2 crupest-77c5f0d98f8318c8ec99fee64591b0701e270224.zip |
tools(aio): move aio and related scripts.
Diffstat (limited to 'tool/modules/backup.py')
-rw-r--r-- | tool/modules/backup.py | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/tool/modules/backup.py b/tool/modules/backup.py deleted file mode 100644 index 7921d0d..0000000 --- a/tool/modules/backup.py +++ /dev/null @@ -1,41 +0,0 @@ -from .path import * -from rich.prompt import Prompt, Confirm -from urllib.request import urlretrieve -import subprocess -from datetime import datetime - - -def backup_restore(http_url_or_path, /, console): - url = http_url_or_path - if len(url) == 0: - raise Exception("You specify an empty url. Abort.") - if url.startswith("http://") or url.startswith("https://"): - download_path = os.path.join(tmp_dir, "data.tar.xz") - if os.path.exists(download_path): - to_remove = Confirm.ask( - f"I want to download to [cyan]{download_path}[/]. However, there is a file already there. Do you want to remove it first", default=False, console=console) - if to_remove: - os.remove(download_path) - else: - raise Exception( - "Aborted! Please check the file and try again.") - urlretrieve(url, download_path) - url = download_path - subprocess.run(["sudo", "tar", "-xJf", url, "-C", project_dir], check=True) - - -def backup_backup(path, /, console): - ensure_backup_dir() - now = datetime.utcnow().isoformat(timespec="seconds") + "Z" - if path is None: - path = Prompt.ask( - "You don't specify the path to backup to. Please specify one. http and https are NOT supported", console=console, default=os.path.join(backup_dir, now + ".tar.xz")) - if len(path) == 0: - raise Exception("You specify an empty path. Abort!") - if os.path.exists(path): - raise Exception( - "A file is already there. Please remove it first. Abort!") - subprocess.run( - ["sudo", "tar", "-cJf", path, "data", "-C", project_dir], - check=True - ) |