Skip to content

Instantly share code, notes, and snippets.

@amenophis1er
Last active January 1, 2023 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amenophis1er/c400369732a981a0ab7d3db654e35cd7 to your computer and use it in GitHub Desktop.
Save amenophis1er/c400369732a981a0ab7d3db654e35cd7 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "------------------- END --------------------"
# Extract DB Credentials
echo "====> EXTRACT DB CREDENTIALS"
WPDBNAME=`cat wp-config.php | grep DB_NAME | cut -d \' -f 4`
WPDBUSER=`cat wp-config.php | grep DB_USER | cut -d \' -f 4`
WPDBPASS=`cat wp-config.php | grep DB_PASSWORD | cut -d \' -f 4`
# Dump MySQL Data
echo "====> DUMP DB"
mysqldump -u ${WPDBUSER} -p${WPDBPASS} ${WPDBNAME} > dump-$(date +%Y%m%d).sql
# The name of our archive
archive_name="archive_$(date +%Y%m%d).tgz"
# Copy .htaccess to htaccess.txt
echo "====> COPY HTACCESS"
cp .htaccess htaccess.txt
# Create the tarball
echo "====> CREATE TARBAL"
tar cfvz ${archive_name} *
# Display Stat of Dump files ...
echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
stat dump-$(date +%Y%m%d).sql
# ... And for the archives itself
echo -e "\n-------------------------\n"
stat ${archive_name}
echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Delete the dump. Already in the archive
rm -f dump-$(date +%Y%m%d).sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment