Browse Source

Update comments
Don't show error message when executing `ls` command

Signed-off-by: Teddysun <[email protected]>

Teddysun 3 years ago
parent
commit
f0f1a1fb2f
1 changed files with 5 additions and 5 deletions
  1. 5 5
      backup.sh

+ 5 - 5
backup.sh

@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright (C) 2013 - 2020 Teddysun <[email protected]>
+# Copyright (C) 2013 - 2022 Teddysun <[email protected]>
 # 
 # This file is part of the LAMP script.
 #
@@ -168,7 +168,7 @@ EOF
             log "MySQL root password is incorrect. Please check it and try again"
             exit 1
         fi
-        if [ "${MYSQL_DATABASE_NAME[@]}" == "" ]; then
+        if [[ "${MYSQL_DATABASE_NAME[@]}" == "" ]]; then
             mysqldump -u root -p"${MYSQL_ROOT_PASSWORD}" --all-databases > "${SQLFILE}" 2>/dev/null
             if [ $? -ne 0 ]; then
                 log "MySQL all databases backup failed"
@@ -218,7 +218,7 @@ start_backup() {
     fi
 
     # Delete MySQL temporary dump file
-    for sql in $(ls ${TEMPDIR}*.sql); do
+    for sql in $(ls ${TEMPDIR}*.sql 2> /dev/null); do
         log "Delete MySQL temporary dump file: ${sql}"
         rm -f ${sql}
     done
@@ -336,9 +336,9 @@ EOF
 clean_up_files() {
     cd ${LOCALDIR} || exit
     if ${ENCRYPTFLG}; then
-        LS=($(ls *.enc))
+        LS=($(ls *.enc 2> /dev/null))
     else
-        LS=($(ls *.tgz))
+        LS=($(ls *.tgz 2> /dev/null))
     fi
     for f in ${LS[@]}; do
         get_file_date ${f}