From 87632446dc9fb059b6de41bab5418dd7c5ed0e3c Mon Sep 17 00:00:00 2001 From: Phoo Pwint Wai Date: Thu, 20 Aug 2026 14:32:39 +0900 Subject: [PATCH 1/8] Fix ambiguous -c short option --- README.md | 2 +- concretecms-backup.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6ba5c04..f109f5d 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ back up a SQL and the files in application/files, application/config/generated_o back up a SQL and the files in application/config/generated_overrides, application/config/doctrine and application/language files. - [no option] - --config -- -c +- -config #### DATABASE option diff --git a/concretecms-backup.sh b/concretecms-backup.sh index 2cd2260..252e3ea 100644 --- a/concretecms-backup.sh +++ b/concretecms-backup.sh @@ -77,7 +77,7 @@ elif [ "$1" = "--database" ] || [ "$1" = "-d" ]; then TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql" TAR_OPTION_EXCLUDE="${EXCLUDE_OPTION}" NO_OPTION="0" -elif [ "$1" = "--config" ] || [ "$1" = "-config" ] || [ "$1" = "-c" ]; then +elif [ "$1" = "--config" ] || [ "$1" = "-config" ]; then echo "c5 Backup: You've chosen the CONFIG option. Now we're backing up the SQL generated_overrides, doctrine files and language files." TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql ${BASE_PATH}/application/config/doctrine ${BASE_PATH}/application/config/generated_overrides ${BASE_PATH}/application/languages" TAR_OPTION_EXCLUDE="${EXCLUDE_OPTION}" @@ -100,7 +100,7 @@ elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then --all-files OR -af: back up all files and folders except the database --all-c5 OR -c: back up a SQL and all concrete5 related files under WHERE_IS_CONCRETE5 path --all OR -a: back up a SQL and ALL files under WHERE_IS_CONCRETE5 path - --config OR -c: backup a SQL and generated_overrides and doctine files + --config OR -config: backup a SQL and generated_overrides and doctrine files --database OR -d: back up only a SQL dump --packages OR --package OR -p: back up a SQL, and the files in application/, packages/ --help OR -h: This help option. @@ -210,4 +210,4 @@ echo "c5 Backup: Now moving the backup file(s) to the final destination..." echo "${WHERE_TO_SAVE}" mv ${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.tar.gz ${WHERE_TO_SAVE} -echo "c5 Backup: Backup completed successfully!" \ No newline at end of file +echo "c5 Backup: Backup completed successfully!" From 964c0f57134b5a5837e43940c194d1e9d1b3a7db Mon Sep 17 00:00:00 2001 From: Phoo Pwint Wai Date: Thu, 20 Aug 2026 14:35:14 +0900 Subject: [PATCH 2/8] Fix ambiguous -c option by assigning -C to config --- README.md | 2 +- concretecms-backup.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f109f5d..c401b6b 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ back up a SQL and the files in application/files, application/config/generated_o back up a SQL and the files in application/config/generated_overrides, application/config/doctrine and application/language files. - [no option] - --config -- -config +- -C #### DATABASE option diff --git a/concretecms-backup.sh b/concretecms-backup.sh index 252e3ea..a139c12 100644 --- a/concretecms-backup.sh +++ b/concretecms-backup.sh @@ -77,7 +77,7 @@ elif [ "$1" = "--database" ] || [ "$1" = "-d" ]; then TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql" TAR_OPTION_EXCLUDE="${EXCLUDE_OPTION}" NO_OPTION="0" -elif [ "$1" = "--config" ] || [ "$1" = "-config" ]; then +elif [ "$1" = "--config" ] || [ "$1" = "-config" ] || [ "$1" = "-C" ]; then echo "c5 Backup: You've chosen the CONFIG option. Now we're backing up the SQL generated_overrides, doctrine files and language files." TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql ${BASE_PATH}/application/config/doctrine ${BASE_PATH}/application/config/generated_overrides ${BASE_PATH}/application/languages" TAR_OPTION_EXCLUDE="${EXCLUDE_OPTION}" @@ -100,7 +100,7 @@ elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then --all-files OR -af: back up all files and folders except the database --all-c5 OR -c: back up a SQL and all concrete5 related files under WHERE_IS_CONCRETE5 path --all OR -a: back up a SQL and ALL files under WHERE_IS_CONCRETE5 path - --config OR -config: backup a SQL and generated_overrides and doctrine files + --config OR -C: backup a SQL and generated_overrides and doctrine files --database OR -d: back up only a SQL dump --packages OR --package OR -p: back up a SQL, and the files in application/, packages/ --help OR -h: This help option. From 70249666160af3a00953cdb5cd0728eb57830552 Mon Sep 17 00:00:00 2001 From: Phoo Pwint Wai Date: Thu, 20 Aug 2026 14:58:16 +0900 Subject: [PATCH 3/8] support --files option --- concretecms-backup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/concretecms-backup.sh b/concretecms-backup.sh index 2cd2260..f70aa04 100644 --- a/concretecms-backup.sh +++ b/concretecms-backup.sh @@ -82,7 +82,7 @@ elif [ "$1" = "--config" ] || [ "$1" = "-config" ] || [ "$1" = "-c" ]; then TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql ${BASE_PATH}/application/config/doctrine ${BASE_PATH}/application/config/generated_overrides ${BASE_PATH}/application/languages" TAR_OPTION_EXCLUDE="${EXCLUDE_OPTION}" NO_OPTION="0" -elif [ "$1" = "--file" ] || [ "$1" = "-files" ] || [ "$1" = "-f" ] || [ "$1" = "" ]; then +elif [ "$1" = "--files" ] || [ "$1" = "--file" ] || [ "$1" = "-files" ] || [ "$1" = "-f" ] || [ "$1" = "" ]; then echo "c5 Backup: You've chosen the DEFAULT FILE option. Now we're backing up the SQL, application/files, config/generated_overrides config/doctrine files, and language files" TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql ${BASE_PATH}/application/files/ ${BASE_PATH}/application/config/doctrine ${BASE_PATH}/application/config/generated_overrides ${BASE_PATH}/application/languages" TAR_OPTION_EXCLUDE="--exclude ${BASE_PATH}/application/files/cache/ ${EXCLUDE_OPTION}" @@ -210,4 +210,4 @@ echo "c5 Backup: Now moving the backup file(s) to the final destination..." echo "${WHERE_TO_SAVE}" mv ${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.tar.gz ${WHERE_TO_SAVE} -echo "c5 Backup: Backup completed successfully!" \ No newline at end of file +echo "c5 Backup: Backup completed successfully!" From 9ef96339a0fd455dce89b036752fee30c3153b9c Mon Sep 17 00:00:00 2001 From: Phoo Pwint Wai Date: Thu, 20 Aug 2026 15:37:34 +0900 Subject: [PATCH 4/8] change options : c = config, C = All C5 --- README.md | 4 ++-- concretecms-backup.sh | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c401b6b..ed57ad7 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ back up a SQL and the files in application/files, application/config/generated_o back up a SQL and the files in application/config/generated_overrides, application/config/doctrine and application/language files. - [no option] - --config -- -C +- -c #### DATABASE option @@ -108,7 +108,7 @@ back up a SQL, and application, concrete, packages, updates folders and composer This is useful option if the Concrete CMS root directory contains many non-Concrete CMS folders. It won't backup any other non-Concrete CMS files on the Concrete CMS document root directory such as sitemap.xml, site verification files. - --all-c5 -- -c +- -C #### HELP option diff --git a/concretecms-backup.sh b/concretecms-backup.sh index a139c12..94ea1ae 100644 --- a/concretecms-backup.sh +++ b/concretecms-backup.sh @@ -57,7 +57,7 @@ elif [ "$1" = "--c5-min" ] || [ "$1" = "--c5-minimum" ] || [ "$1" = "-cm" ]; the TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql ${BASE_PATH}/application/ ${BASE_PATH}/concrete/ ${BASE_PATH}/packages/ ${BASE_PATH}/updates/ ${BASE_PATH}/composer.json ${BASE_PATH}/composer.lock ${BASE_PATH}/index.php ${BASE_PATH}/robots.txt" TAR_OPTION_EXCLUDE="--exclude ${BASE_PATH}/application/files/ ${EXCLUDE_OPTION}" NO_OPTION="0" -elif [ "$1" = "--all-c5" ] || [ "$1" = "-c" ]; then +elif [ "$1" = "--all-c5" ] || [ "$1" = "-C" ]; then echo "c5 Backup: You've chosen the all concrete5 option. Now we're backing up the SQL, application/ concrete/, packages/ folders and concrete5 files." TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql ${BASE_PATH}/application/ ${BASE_PATH}/concrete/ ${BASE_PATH}/packages/ ${BASE_PATH}/updates/ ${BASE_PATH}/composer.json ${BASE_PATH}/composer.lock ${BASE_PATH}/index.php ${BASE_PATH}/robots.txt" TAR_OPTION_EXCLUDE="--exclude ${BASE_PATH}/application/files/cache/ ${EXCLUDE_OPTION}" @@ -77,7 +77,7 @@ elif [ "$1" = "--database" ] || [ "$1" = "-d" ]; then TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql" TAR_OPTION_EXCLUDE="${EXCLUDE_OPTION}" NO_OPTION="0" -elif [ "$1" = "--config" ] || [ "$1" = "-config" ] || [ "$1" = "-C" ]; then +elif [ "$1" = "--config" ] || [ "$1" = "-config" ] || [ "$1" = "-c" ]; then echo "c5 Backup: You've chosen the CONFIG option. Now we're backing up the SQL generated_overrides, doctrine files and language files." TAR_OPTION="${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.sql ${BASE_PATH}/application/config/doctrine ${BASE_PATH}/application/config/generated_overrides ${BASE_PATH}/application/languages" TAR_OPTION_EXCLUDE="${EXCLUDE_OPTION}" @@ -98,9 +98,9 @@ elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then --files OR --file OR -f: back up a SQL and the files in application/files. This is default option. --c5-minimum OR --c5-min OR -cm: back up a SQL, application EXCEPT files, concrete, packages and root concrete5 files --all-files OR -af: back up all files and folders except the database - --all-c5 OR -c: back up a SQL and all concrete5 related files under WHERE_IS_CONCRETE5 path + --all-c5 OR -C: back up a SQL and all concrete5 related files under WHERE_IS_CONCRETE5 path --all OR -a: back up a SQL and ALL files under WHERE_IS_CONCRETE5 path - --config OR -C: backup a SQL and generated_overrides and doctrine files + --config OR -c: backup a SQL and generated_overrides and doctrine files --database OR -d: back up only a SQL dump --packages OR --package OR -p: back up a SQL, and the files in application/, packages/ --help OR -h: This help option. From a9de57e4a6a2f83e33463e56c461b83f2b628a36 Mon Sep 17 00:00:00 2001 From: Phoo Pwint Wai Date: Thu, 20 Aug 2026 16:07:47 +0900 Subject: [PATCH 5/8] Fix POSIX sh compatibility for exclude parsing --- concretecms-backup.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/concretecms-backup.sh b/concretecms-backup.sh index 2cd2260..d0de81e 100644 --- a/concretecms-backup.sh +++ b/concretecms-backup.sh @@ -20,7 +20,7 @@ set -e # concretecms-backup.conf should be stored in the same directory as concretecms-backup.sh #----------------------------------------------------------- -source ./concretecms-backup.conf +. ./concretecms-backup.conf # ============================== # @@ -40,12 +40,22 @@ fi # Parse the third option for exclusions EXCLUDE_OPTION="" -if [ -n "$3" ]; then - IFS=',' read -r -a EXCLUDE_DIRS <<< "$3" - for DIR in "${EXCLUDE_DIRS[@]}"; do - EXCLUDE_OPTION+="--exclude ${BASE_PATH}/${DIR} " - done -fi +EXCLUDE_DIRS=$3 +while [ -n "$EXCLUDE_DIRS" ]; do + case "$EXCLUDE_DIRS" in + *,*) + DIR=${EXCLUDE_DIRS%%,*} + EXCLUDE_DIRS=${EXCLUDE_DIRS#*,} + ;; + *) + DIR=$EXCLUDE_DIRS + EXCLUDE_DIRS="" + ;; + esac + if [ -n "$DIR" ]; then + EXCLUDE_OPTION="${EXCLUDE_OPTION}--exclude ${BASE_PATH}/${DIR} " + fi +done if [ "$1" = "--all" ] || [ "$1" = "-a" ]; then echo "c5 Backup: You've chosen the ALL option. Now we're backing up all concrete5 directory files." @@ -210,4 +220,4 @@ echo "c5 Backup: Now moving the backup file(s) to the final destination..." echo "${WHERE_TO_SAVE}" mv ${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.tar.gz ${WHERE_TO_SAVE} -echo "c5 Backup: Backup completed successfully!" \ No newline at end of file +echo "c5 Backup: Backup completed successfully!" From 5f3b1c48c82307977b6c9f570f7a9a9e1f1d9ec1 Mon Sep 17 00:00:00 2001 From: Phoo Pwint Wai Date: Thu, 20 Aug 2026 17:10:08 +0900 Subject: [PATCH 6/8] Fix successful exit codes on backup validation errors --- concrete5-copy.sh | 2 +- concretecms-backup.sh | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/concrete5-copy.sh b/concrete5-copy.sh index a96f733..fd9ed73 100644 --- a/concrete5-copy.sh +++ b/concrete5-copy.sh @@ -46,7 +46,7 @@ elif [ "$ORIGIN_MYSQL_IF_NO_TABLESPACE" = "FALSE" ] || [ "$ORIGIN_MYSQL_IF_NO_TA MYSQLDUMP_OPTION_TABLESPACE="" else echo "c5 Backup ERROR: ORIGIN_MYSQL_IF_NO_TABLESPACE variable is not properly set in the shell script" - exit + exit 1 fi # ---- Starting shell ----- diff --git a/concretecms-backup.sh b/concretecms-backup.sh index 2cd2260..b392d73 100644 --- a/concretecms-backup.sh +++ b/concretecms-backup.sh @@ -118,14 +118,14 @@ elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then Have a good day! " - exit + exit 0 else NO_OPTION="1" fi if [ "$NO_OPTION" = "1" ] || [ "$NO_2nd_OPTION" = "1" ]; then echo "c5 Backup ERROR: You specified WRONG OPTION. Please try 'sh concrete5-backup.sh -h' for the available options." - exit + exit 1 fi # ---- tablespace option after MySQL 5.7.31 @@ -135,34 +135,34 @@ elif [ "$MYSQL_IF_NO_TABLESPACE" = "FALSE" ] || [ "$MYSQL_IF_NO_TABLESPACE" = "F MYSQLDUMP_OPTION_TABLESPACE="" else echo "c5 Backup ERROR: MYSQL_IF_NO_TABLESPACE variable is not properly set in the shell script" - exit + exit 1 fi # ---- Checking Variable ----- echo "c5 Backup: Checking variables..." if [ -z "$WHERE_TO_SAVE" ] || [ "$WHERE_TO_SAVE" = " " ]; then echo "c5 Backup ERROR: WHERE_TO_SAVE variable is not set in the shell script" - exit + exit 1 fi if [ -z "$WHERE_IS_CONCRETE5" ] || [ "$WHERE_IS_CONCRETE5" = " " ]; then echo "c5 Backup ERROR: WHERE_IS_CONCRETE5 variable is not set in the shell script" - exit + exit 1 fi if [ -z "$NOW_TIME" ] || [ "$NOW_TIME" = " " ]; then echo "c5 Backup ERROR: NOW_TIME variable is not set in the shell script" - exit + exit 1 fi if [ -z "$MYSQL_SERVER" ] || [ "$MYSQL_SERVER" = " " ]; then echo "c5 Backup ERROR: MYSQL_SERVER variable is not set in the shell script" - exit + exit 1 fi if [ -z "$MYSQL_USER" ] || [ "$MYSQL_USER" = " " ]; then echo "c5 Backup ERROR: MYSQL_USER variable is not set in the shell script" - exit + exit 1 fi if [ -z "$MYSQL_NAME" ] || [ "$MYSQL_NAME" = " " ]; then echo "c5 Backup ERROR: MYSQL_NAME variable is not set in the shell script" - exit + exit 1 fi # ---- Starting shell ----- @@ -210,4 +210,4 @@ echo "c5 Backup: Now moving the backup file(s) to the final destination..." echo "${WHERE_TO_SAVE}" mv ${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.tar.gz ${WHERE_TO_SAVE} -echo "c5 Backup: Backup completed successfully!" \ No newline at end of file +echo "c5 Backup: Backup completed successfully!" From ba29c5438a6a8f6e9797b5594845241c855a485f Mon Sep 17 00:00:00 2001 From: Phoo Pwint Wai Date: Thu, 20 Aug 2026 17:13:33 +0900 Subject: [PATCH 7/8] correct script name in invalid-option error --- concretecms-backup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/concretecms-backup.sh b/concretecms-backup.sh index 2cd2260..8dbce7f 100644 --- a/concretecms-backup.sh +++ b/concretecms-backup.sh @@ -124,7 +124,7 @@ else fi if [ "$NO_OPTION" = "1" ] || [ "$NO_2nd_OPTION" = "1" ]; then - echo "c5 Backup ERROR: You specified WRONG OPTION. Please try 'sh concrete5-backup.sh -h' for the available options." + echo "c5 Backup ERROR: You specified WRONG OPTION. Please try 'sh concretecms-backup.sh -h' for the available options." exit fi @@ -210,4 +210,4 @@ echo "c5 Backup: Now moving the backup file(s) to the final destination..." echo "${WHERE_TO_SAVE}" mv ${BASE_PATH}/${FILE_NAME}_${NOW_TIME}.tar.gz ${WHERE_TO_SAVE} -echo "c5 Backup: Backup completed successfully!" \ No newline at end of file +echo "c5 Backup: Backup completed successfully!" From 25b6a095e0c1d52ce04e3e0349aa74bfcc1d65d1 Mon Sep 17 00:00:00 2001 From: Phoo Pwint Wai <132864075+phoopw@users.noreply.github.com> Date: Mon, 24 Aug 2026 07:42:31 +0900 Subject: [PATCH 8/8] Update concretecms-backup.sh add 1 after exit --- concretecms-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concretecms-backup.sh b/concretecms-backup.sh index 081f687..8c00730 100644 --- a/concretecms-backup.sh +++ b/concretecms-backup.sh @@ -125,7 +125,7 @@ fi if [ "$NO_OPTION" = "1" ] || [ "$NO_2nd_OPTION" = "1" ]; then echo "c5 Backup ERROR: You specified WRONG OPTION. Please try 'sh concretecms-backup.sh -h' for the available options." - exit + exit 1 fi # ---- tablespace option after MySQL 5.7.31