From bdba80ace15ba6f1a598f1b70bef3bac4a5a1d2c Mon Sep 17 00:00:00 2001 From: Foxly IT <81775975+foxly-it@users.noreply.github.com> Date: Sat, 27 Apr 2024 09:20:40 +0200 Subject: [PATCH] Update backupcpv2.sh Revision of the script for the current CloudPanel v2. It is now necessary to enter a specific database to be backed up. --- backupcpv2.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/backupcpv2.sh b/backupcpv2.sh index 9fbeb28..7a08ec4 100755 --- a/backupcpv2.sh +++ b/backupcpv2.sh @@ -11,7 +11,7 @@ NUM_CORES=$(nproc || echo 1) # You need to adjust the settings in the # # TODO section for yourself # # Author : Mark Schenk # -# Date : 2022-05-21 14:08 # +# Date : 2024-04-27 14:08 # # License : MIT # # Version : 2.0.0 # # # @@ -21,8 +21,8 @@ NUM_CORES=$(nproc || echo 1) # TODO / Variables # ####################### -# Which PHP version do you use e.g. 7.3 , 7.4 , 8.0 -phpversion="8.1" +# Which PHP version do you use e.g. 8.2, 8.3 +phpversion="8.2" # Just adjust the domain here e.g. cloud.example.org or example.org domain="cloud.example.tld" @@ -31,7 +31,8 @@ domain="cloud.example.tld" backupPassword="P@ssw0rd" # Here you have to specify the path to the Borg repository. -backupRepo="/mnt/" +backupRepo="/mnt/backup" +backupDatabase="/mnt/backup/database" # You must edit this user to Site User from the Domain. siteUser="User" @@ -129,11 +130,16 @@ sudo -u $siteUser php$phpversion $ncLocation$domain/occ maintenance:mode --on echo "" # DATABASES: Remove "#" for the correct database -# You can backup only all databases in CPv2 specific databases. +# You have to enter a specific database. It is no longer possible to save all databases at the same time. -echo -e "\e[93mStart MariaDB/MySQL database backup" +#################### +# MySQL Backup # +#################### + +echo -e "\e[93mStart MySQL database backup" + +bash clpctl db:export --databaseName=DATABASENAME --file=$backupDatabase/backup_$(date +%d-%m-%Y).sql.gz -su -s /bin/bash -c '/usr/bin/clpctl db:backup --retentionPeriod=7' clp echo -e "${FGREEN}Backup has been finished successfully after $(displaytime $(($(date +%s) - START)))!${FEND}" @@ -144,9 +150,6 @@ echo -e "${FGREEN}Backup has been finished successfully after $(displaytime $(($ # Script # ####################### - - - export BORG_REPO=$backupRepo export BORG_PASSPHRASE=$backupPassword @@ -196,4 +199,4 @@ elif [ ${global_exit} -eq 1 ]; then else echo -e "${FRED}Backup und/oder Prune beendet mit Fehlern nach $(displaytime $(($(date +%s) - START)))!${FEND}" fi -exit ${global_exit} +exit ${global_exit} \ No newline at end of file