-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from russellmacshane/dev
Dev into Master
- Loading branch information
Showing
4 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.vagrant | ||
*.log | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
source /quick-wordpress/config | ||
|
||
echo "***************************** WordPress Backup **************************" | ||
run=true | ||
while $run | ||
do | ||
read -r -p "Would you like to name your backup? [Y/n] " input | ||
|
||
case $input in | ||
[yY][eE][sS]|[yY]) | ||
read -p "Enter the filename of your backup: " file | ||
backup_file=$file.tar.bz2 | ||
echo "Will name backup $backup_file" | ||
run=false | ||
;; | ||
|
||
[nN][oO]|[nN]) | ||
backup_file=$(date '+%F_%s').tar.bz2 | ||
echo "Will name backup $backup_file" | ||
run=false | ||
;; | ||
|
||
*) | ||
echo "Invalid input..." | ||
;; | ||
esac | ||
done | ||
|
||
echo "***************************** Backup Database ****************************" | ||
sudo mysqldump $wp_db > datadump.sql | ||
|
||
echo "***************************** Backups Files ******************************" | ||
mkdir -p /quick-wordpress/backup | ||
tar -cjvf /quick-wordpress/backup/$backup_file /var/www/html datadump.sql | ||
|
||
echo "***************************** Cleanup ************************************" | ||
rm datadump.sql |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
source /quick-wordpress/config | ||
|
||
echo "***************************** WordPress Restore **************************" | ||
read -p "Enter the filename of the backup you would like to restore: " file | ||
|
||
backup_file=/quick-wordpress/backup/$file | ||
|
||
if [ ! -f $backup_file ]; then | ||
echo "$backup_file not found!" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
echo "***************************** Unpack Backup ******************************" | ||
mkdir -p /tmp/wp-bkup | ||
tar -xjvf $backup_file -C /tmp/wp-bkup | ||
|
||
echo "***************************** Nuke WP Installation ***********************" | ||
sudo rm -rf /var/www/html/* | ||
|
||
echo "***************************** Restore Files ******************************" | ||
sudo mv /tmp/wp-bkup/var/www/html/* /var/www/html/ | ||
|
||
echo "***************************** Restore Database ***************************" | ||
sudo mysql $wp_db < /tmp/wp-bkup/datadump.sql | ||
|
||
echo "***************************** Cleanup ************************************" | ||
rm -rf /tmp/wp-bkup |