12345678910111213141516171819202122232425262728293031323334353637383940 |
- #!/bin/bash
- if [ -z "$1" ]; then
- echo "Usage: $0 <site code>"
- exit 1
- fi
- DEST_DIR="/home/ec2-user/template_temp"
- SOURCE_DIR="/var/www/"
- DB_NAME="$1"
- DB_USER="root"
- DB_PASSWORD="UXG2YHf8YbrQTvFJKej7CnhLfGEWB44B"
- DATE=$(date +"%Y%m%d%H%M%S")
- TAR_FILE="$DEST_DIR/$1.tar.gz"
- cd $SOURCE_DIR;
- tar -czf $TAR_FILE $1
- DB_DUMP_FILE="$DEST_DIR/$1.sql"
- mysqldump -u "$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" > "$DB_DUMP_FILE"
- if [ $? -eq 0 ]; then
- echo "Directory packed to $TAR_FILE"
- echo "Database dumped to $DB_DUMP_FILE"
- else
- echo "An error occurred during packaging or database export"
- exit 1
- fi
|