12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #!/bin/bash
- SITE_CODE=$1
- FROM_DIR="/usr/local/wwwroot/"
- DIR_TO_CHECK=$FROM_DIR$SITE_CODE
- TARGET_DIR="/opt/adweb3/wp_bak/"
- RDS_HOST='127.0.0.1'
- RDS_ADMIN='root'
- RDS_PWD='Initial0_123'
- if [ -d "$DIR_TO_CHECK" ]; then
-
-
-
-
- cd $FROM_DIR
- echo "开始打包项目到$TARGET_DIR$SITE_CODE.tar.gz"
- sudo tar -czf $TARGET_DIR$SITE_CODE.tar.gz $SITE_CODE
-
- if [ $? -eq 0 ]; then
- echo "目标项目已经成功打包到$TARGET_DIR$SITE_CODE.tar.gz"
- else
- echo "Failed to move the directory."
- fi
-
-
-
- mysqldump --user=$RDS_ADMIN --password=$RDS_PWD --host=localhost --port=3306 --no-create-db --default-character-set=utf8 $SITE_CODE > $TARGET_DIR$SITE_CODE.sql
-
- if [ $? -eq 0 ]; then
- echo "Database $SITE_CODE has been backup."
- else
- echo "Failed to backup database $SITE_CODE."
- fi
- fi
|