Last active
January 1, 2023 23:38
-
-
Save amenophis1er/c400369732a981a0ab7d3db654e35cd7 to your computer and use it in GitHub Desktop.
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 | |
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