Browse Source

Fix backup.sh

lj2007331@gmail.com 6 years ago
parent
commit
5757e60494
7 changed files with 48 additions and 18 deletions
  1. 39 11
      backup.sh
  2. 1 1
      backup_setup.sh
  3. 1 0
      config/drupal.conf
  4. 1 0
      include/ZendGuardLoader.sh
  5. 1 1
      include/memory.sh
  6. 4 4
      versions.txt
  7. 1 1
      vhost.sh

+ 39 - 11
backup.sh

@@ -41,7 +41,10 @@ DB_OSS_BK() {
     DB_GREP="DB_${D}_`date +%Y%m%d`"
     DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
     /usr/local/bin/ossutil cp -f ${backup_dir}/${DB_FILE} oss://${oss_bucket}/`date +%F`/${DB_FILE}
-    [ $? -eq 0 ] && /usr/local/bin/ossutil rm -rf oss://${oss_bucket}/`date +%F --date="${expired_days} days ago"`/
+    if [ $? -eq 0 ]; then
+      /usr/local/bin/ossutil rm -rf oss://${oss_bucket}/`date +%F --date="${expired_days} days ago"`/
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE}
+    fi
   done
 }
 
@@ -52,7 +55,10 @@ DB_COS_BK() {
     DB_GREP="DB_${D}_`date +%Y%m%d`"
     DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
     ${python_install_dir}/bin/coscmd upload ${backup_dir}/${DB_FILE} /`date +%F`/${DB_FILE}
-    [ $? -eq 0 ] && ${python_install_dir}/bin/coscmd delete -r -f `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+    if [ $? -eq 0 ]; then
+      ${python_install_dir}/bin/coscmd delete -r -f `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE}
+    fi
   done
 }
 
@@ -63,7 +69,10 @@ DB_UPYUN_BK() {
     DB_GREP="DB_${D}_`date +%Y%m%d`"
     DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
     /usr/local/bin/upx put ${backup_dir}/${DB_FILE} /`date +%F`/${DB_FILE}
-    [ $? -eq 0 ] && /usr/local/bin/upx rm -a `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+    if [ $? -eq 0 ]; then
+      /usr/local/bin/upx rm -a `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE}
+    fi
   done
 }
 
@@ -77,6 +86,7 @@ DB_QINIU_BK() {
     if [ $? -eq 0 ]; then
       /usr/local/bin/qshell listbucket ${qiniu_bucket} /`date +%F --date="${expired_days} days ago"` /tmp/qiniu.txt > /dev/null 2>&1
       /usr/local/bin/qshell batchdelete -force ${qiniu_bucket} /tmp/qiniu.txt > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE}
       rm -f /tmp/qiniu.txt
     fi
   done
@@ -89,7 +99,10 @@ DB_S3_BK() {
     DB_GREP="DB_${D}_`date +%Y%m%d`"
     DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
     ${python_install_dir}/bin/s3cmd put ${backup_dir}/${DB_FILE} s3://${s3_bucket}/`date +%F`/${DB_FILE}
-    [ $? -eq 0 ] && ${python_install_dir}/bin/s3cmd rm -r s3://${s3_bucket}/`date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+    if [ $? -eq 0 ]; then
+      ${python_install_dir}/bin/s3cmd rm -r s3://${s3_bucket}/`date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE}
+    fi
   done
 }
 
@@ -110,6 +123,7 @@ DB_GDRIVE_BK() {
     if [ $? -eq 0 ]; then
       Parent_expired_id=$(/usr/local/bin/gdrive list --no-header -q "'${Parent_root_id}' in parents and trashed = false and name = '`date +%F --date="${expired_days} days ago"`'" | awk '{print $1}')
       [ -n "${Parent_expired_id}" ] && /usr/local/bin/gdrive delete -r ${Parent_expired_id} > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE}
     fi
   done
 }
@@ -121,7 +135,10 @@ DB_DROPBOX_BK() {
     DB_GREP="DB_${D}_`date +%Y%m%d`"
     DB_FILE=`ls -lrt ${backup_dir} | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
     /usr/local/bin/dbxcli put ${backup_dir}/${DB_FILE} `date +%F`/${DB_FILE}
-    [ $? -eq 0 ] && /usr/local/bin/dbxcli rm -f `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+    if [ $? -eq 0 ]; then
+      /usr/local/bin/dbxcli rm -f `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${backup_dir}/${DB_FILE}
+    fi
   done
 }
 
@@ -158,7 +175,10 @@ WEB_OSS_BK() {
       popd > /dev/null
     fi
     /usr/local/bin/ossutil cp -f ${PUSH_FILE} oss://${oss_bucket}/`date +%F`/${PUSH_FILE##*/}
-    [ $? -eq 0 ] && { [ -e "${PUSH_FILE}" ] && rm -rf ${PUSH_FILE}; /usr/local/bin/ossutil rm -rf oss://${oss_bucket}/`date +%F --date="${expired_days} days ago"`/; }
+    if [ $? -eq 0 ]; then
+      /usr/local/bin/ossutil rm -rf oss://${oss_bucket}/`date +%F --date="${expired_days} days ago"`/
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE}
+    fi
   done
 }
 
@@ -175,7 +195,7 @@ WEB_COS_BK() {
     ${python_install_dir}/bin/coscmd upload ${PUSH_FILE} /`date +%F`/${PUSH_FILE##*/}
     if [ $? -eq 0 ]; then
       ${python_install_dir}/bin/coscmd delete -r -f `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
-      [ -e "${PUSH_FILE}" -a -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -rf ${PUSH_FILE}
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE}
     fi
   done
 }
@@ -194,7 +214,7 @@ WEB_UPYUN_BK() {
     /usr/local/bin/upx put ${PUSH_FILE} /`date +%F`/${PUSH_FILE##*/}
     if [ $? -eq 0 ]; then
       /usr/local/bin/upx rm -a `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
-      [ -e "${PUSH_FILE}" -a -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -rf ${PUSH_FILE}
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE}
     fi
   done
 }
@@ -214,6 +234,7 @@ WEB_QINIU_BK() {
     if [ $? -eq 0 ]; then
       /usr/local/bin/qshell listbucket ${qiniu_bucket} /`date +%F --date="${expired_days} days ago"` /tmp/qiniu.txt > /dev/null 2>&1
       /usr/local/bin/qshell batchdelete -force ${qiniu_bucket} /tmp/qiniu.txt > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE}
       rm -f /tmp/qiniu.txt
     fi
   done
@@ -231,7 +252,10 @@ WEB_S3_BK() {
       popd > /dev/null
     fi
     ${python_install_dir}/bin/s3cmd put ${PUSH_FILE} s3://${s3_bucket}/`date +%F`/${PUSH_FILE##*/}
-    [ $? -eq 0 ] && ${python_install_dir}/bin/s3cmd rm -r s3://${s3_bucket}/`date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+    if [ $? -eq 0 ]; then
+      ${python_install_dir}/bin/s3cmd rm -r s3://${s3_bucket}/`date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE}
+    fi
   done
 }
 
@@ -253,10 +277,11 @@ WEB_GDRIVE_BK() {
       tar czf ${PUSH_FILE} ./$W
       popd > /dev/null
     fi
-    /usr/local/bin/gdrive upload -p ${Parent_sub_id} ${PUSH_FILE} 
+    /usr/local/bin/gdrive upload -p ${Parent_sub_id} ${PUSH_FILE}
     if [ $? -eq 0 ]; then
       Parent_expired_id=$(/usr/local/bin/gdrive list --no-header -q "'${Parent_root_id}' in parents and trashed = false and name = '`date +%F --date="${expired_days} days ago"`'" | awk '{print $1}')
       [ -n "${Parent_expired_id}" ] && /usr/local/bin/gdrive delete -r ${Parent_expired_id} > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE}
     fi
   done
 }
@@ -273,7 +298,10 @@ WEB_DROPBOX_BK() {
       popd > /dev/null
     fi
     /usr/local/bin/dbxcli put ${PUSH_FILE} `date +%F`/${PUSH_FILE##*/}
-    [ $? -eq 0 ] && /usr/local/bin/dbxcli rm -f `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+    if [ $? -eq 0 ]; then
+      /usr/local/bin/dbxcli rm -f `date +%F --date="${expired_days} days ago"` > /dev/null 2>&1
+      [ -z "`echo ${backup_destination} | grep -ow 'local'`" ] && rm -f ${PUSH_FILE}
+    fi
   done
 }
 

+ 1 - 1
backup_setup.sh

@@ -184,7 +184,7 @@ fi
 
 if [ -n "`echo ${desc_bk} | grep -w 3`" ]; then
   if [ ! -e "/usr/local/bin/ossutil" ]; then
-    wget -qc http://gosspublic.alicdn.com/ossutil/1.4.2/ossutil${OS_BIT} -O /usr/local/bin/ossutil
+    wget -qc http://gosspublic.alicdn.com/ossutil/1.4.3/ossutil${OS_BIT} -O /usr/local/bin/ossutil
     chmod +x /usr/local/bin/ossutil
   fi
   while :; do echo

+ 1 - 0
config/drupal.conf

@@ -1,3 +1,4 @@
 if (!-e $request_filename) {
+  rewrite ^/update.php(.*)$ /update.php?q=$1 last;
   rewrite ^/(.*)$ /index.php?q=$1 last;
 }

+ 1 - 0
include/ZendGuardLoader.sh

@@ -43,6 +43,7 @@ Install_ZendGuardLoader() {
       esac
 
       if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ]; then
+        chmod 644 ${phpExtensionDir}/ZendGuardLoader.so
         cat > ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini<< EOF
 [Zend Guard Loader]
 zend_extension=${phpExtensionDir}/ZendGuardLoader.so

+ 1 - 1
include/memory.sh

@@ -39,7 +39,7 @@ fi
 
 # add swapfile
 if [ "${Swap}" == '0' ] && [ ${Mem} -le 2048 ]; then
-  echo "${CMSG}Add Swap file, It may take a few minutes... ${CEND}"
+  echo "${CWARNING}Add Swap file, It may take a few minutes... ${CEND}"
   dd if=/dev/zero of=/swapfile count=2048 bs=1M
   mkswap /swapfile
   swapon /swapfile

+ 4 - 4
versions.txt

@@ -25,7 +25,7 @@ mysql56_ver=5.6.43
 mysql55_ver=5.5.62
 
 mariadb103_ver=10.3.12
-mariadb102_ver=10.2.21
+mariadb102_ver=10.2.22
 mariadb101_ver=10.1.38
 mariadb55_ver=5.5.63
 
@@ -36,7 +36,7 @@ percona55_ver=5.5.62-38.14
 
 alisql_ver=5.6.32-9
 
-pgsql_ver=11.1
+pgsql_ver=11.2
 
 mongodb_ver=4.0.6
 
@@ -63,14 +63,14 @@ mcrypt_ver=2.6.8
 mhash_ver=0.9.9.9
 libsodium_ver=1.0.17
 argon2_ver=20171227
-imagemagick_ver=6.9.10-27
+imagemagick_ver=6.9.10-28
 imagick_ver=3.4.3
 graphicsmagick_ver=1.3.30
 gmagick_ver=2.0.5RC1
 gmagick_oldver=1.1.7RC3
 zendopcache_ver=7.0.5
 xcache_ver=3.2.0
-apcu_ver=5.1.16
+apcu_ver=5.1.17
 apcu_oldver=4.0.11
 eaccelerator_ver=0.9.6.1
 phalcon_ver=3.4.2

+ 1 - 1
vhost.sh

@@ -223,7 +223,7 @@ If you enter '.', the field will be left blank.
     read -e -p "Organizational Unit Name (eg, section) [IT Dept.]: " SELFSIGNEDSSL_OU
     SELFSIGNEDSSL_OU=${SELFSIGNEDSSL_OU:-"IT Dept."}
 
-    openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${PATH_SSL}/${domain}.csr -keyout ${PATH_SSL}/${domain}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${domain}" > /dev/null 2>&1
+    openssl req -utf8 -new -newkey rsa:2048 -sha256 -nodes -out ${PATH_SSL}/${domain}.csr -keyout ${PATH_SSL}/${domain}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${domain}" > /dev/null 2>&1
     openssl x509 -req -days 36500 -sha256 -in ${PATH_SSL}/${domain}.csr -signkey ${PATH_SSL}/${domain}.key -out ${PATH_SSL}/${domain}.crt > /dev/null 2>&1
   elif [ "${Domian_Mode}" == '3' -o "${dnsapi_flag}" == 'y' ]; then
     if [ "${moredomain}" == "*.${domain}" -o "${dnsapi_flag}" == 'y' ]; then