Added Backup

This commit is contained in:
Whispering Wind
2024-09-02 23:32:50 +03:30
committed by GitHub
3 changed files with 33 additions and 1 deletions

View File

@ -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

View File

@ -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
if [ $? -eq 0 ]; then
echo "Backup successfully created"
else
echo "Backup failed!"
fi

View File

@ -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