From 76bbd8e350dcc525f9baa2bcb42f6347b917f851 Mon Sep 17 00:00:00 2001 From: Night Owl <176560581+ShadowOwlCode@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:22:10 +0330 Subject: [PATCH 1/4] Create backup.sh --- core/scripts/hysteria2/backup.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 core/scripts/hysteria2/backup.sh diff --git a/core/scripts/hysteria2/backup.sh b/core/scripts/hysteria2/backup.sh new file mode 100644 index 0000000..ec3c473 --- /dev/null +++ b/core/scripts/hysteria2/backup.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +BACKUP_DIR="/opt/hysbackup" +BACKUP_FILE="$BACKUP_DIR/hysteria_backup_$(date +%Y%m%d_%H%M%S).zip" + +if [ ! -d "$BACKUP_DIR" ]; then + mkdir -p "$BACKUP_DIR" +fi + +FILES_TO_BACKUP=( + "/etc/hysteria/ca.key" + "/etc/hysteria/ca.crt" + "/etc/hysteria/users.json" + "/etc/hysteria/config.json" +) + +zip -j "$BACKUP_FILE" "${FILES_TO_BACKUP[@]}" >/dev/null 2>&1 + +if [ $? -eq 0 ]; then + echo "Backup successfully created" +else + echo "Backup failed!" +fi From 4feb6d18bf30eb9fdf6e8c7663eabbf5477842ab Mon Sep 17 00:00:00 2001 From: Night Owl <176560581+ShadowOwlCode@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:22:37 +0330 Subject: [PATCH 2/4] Update Necessary packages --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index c08d75a..cd8f518 100644 --- a/install.sh +++ b/install.sh @@ -10,7 +10,7 @@ if ! command -v jq &> /dev/null || ! command -v git &> /dev/null || ! command -v echo "${yellow}Necessary packages are not installed. Please wait while they are being installed..." sleep 3 echo - apt update && apt upgrade -y && apt install jq qrencode curl pwgen uuid-runtime python3 python3-pip python3-venv git bc -y + apt update && apt upgrade -y && apt install jq qrencode curl pwgen uuid-runtime python3 python3-pip python3-venv git bc zip -y fi git clone https://github.com/ReturnFI/Hysteria2 /etc/hysteria From eebd58b52ff2a2f86a925dc0ef3f2638d7243470 Mon Sep 17 00:00:00 2001 From: Night Owl <176560581+ShadowOwlCode@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:23:47 +0330 Subject: [PATCH 3/4] Added backup hysteria --- core/cli.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/cli.py b/core/cli.py index 913796b..bf87d1b 100644 --- a/core/cli.py +++ b/core/cli.py @@ -31,6 +31,7 @@ class Command(Enum): TRAFFIC_STATUS = 'traffic.py' # won't be call directly (it's a python module) LIST_USERS = os.path.join(SCRIPT_DIR, 'hysteria2', 'list_users.sh') SERVER_INFO = os.path.join(SCRIPT_DIR, 'hysteria2', 'server_info.sh') + BACKUP_HYSTERIA = os.path.join(SCRIPT_DIR, 'hysteria2', 'backup.sh') INSTALL_TELEGRAMBOT = os.path.join(SCRIPT_DIR, 'telegrambot', 'runbot.sh') INSTALL_SINGBOX = os.path.join(SCRIPT_DIR, 'singbox', 'singbox_shell.sh') INSTALL_TCP_BRUTAL = os.path.join(SCRIPT_DIR, 'tcp-brutal', 'install.sh') @@ -224,6 +225,14 @@ def server_info(): output = run_cmd(['bash', Command.SERVER_INFO.value]) if output: print(output) + +@cli.command('backup-hysteria') +def backup_hysteria(): + try: + run_cmd(['bash', Command.BACKUP_HYSTERIA.value]) + except subprocess.CalledProcessError as e: + click.echo(f"Backup failed: {e.output.decode()}", err=True) + # endregion # region advanced menu From 3d169c742acc83f411ea47df31ebd38c01ed0b20 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:32:16 +0330 Subject: [PATCH 4/4] Update backup.sh --- core/scripts/hysteria2/backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/scripts/hysteria2/backup.sh b/core/scripts/hysteria2/backup.sh index ec3c473..199ea1a 100644 --- a/core/scripts/hysteria2/backup.sh +++ b/core/scripts/hysteria2/backup.sh @@ -14,7 +14,7 @@ FILES_TO_BACKUP=( "/etc/hysteria/config.json" ) -zip -j "$BACKUP_FILE" "${FILES_TO_BACKUP[@]}" >/dev/null 2>&1 +zip -j "$BACKUP_FILE" "${FILES_TO_BACKUP[@]}" >/dev/null if [ $? -eq 0 ]; then echo "Backup successfully created"