Last active
December 24, 2016 06:26
-
-
Save SpartakusMd/ef573ea651f9ec46be55 to your computer and use it in GitHub Desktop.
Wordpress Backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment