Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Usage
- # backup.sh path-to-wordpress-folder
- WPDIR=${1:-www}
- echo "Making files backup"
- CurrentDir=${PWD##*/}
- FILENAME="$CurrentDir ($(date '+%F'))"
- tar -czf "$FILENAME.tgz" --exclude="$WPDIR/wp-content/uploads" --exclude-vcs $WPDIR
- echo "Making database backup"
- WPDBHOST=`cat $WPDIR/wp-config.php | grep DB_HOST | cut -d \' -f 4`
- WPDBNAME=`cat $WPDIR/wp-config.php | grep DB_NAME | cut -d \' -f 4`
- WPDBUSER=`cat $WPDIR/wp-config.php | grep DB_USER | cut -d \' -f 4`
- WPDBPASS=`cat $WPDIR/wp-config.php | grep DB_PASSWORD | cut -d \' -f 4`
- mysqldump -h $WPDBHOST -u $WPDBUSER -p$WPDBPASS $WPDBNAME > "$FILENAME.sql" && tar -zcf "$FILENAME.sql.tgz" "$FILENAME.sql" && rm "$FILENAME.sql"
Add Comment
Please, Sign In to add comment