File tree Expand file tree Collapse file tree 4 files changed +80
-3
lines changed
Expand file tree Collapse file tree 4 files changed +80
-3
lines changed Original file line number Diff line number Diff line change 11.vagrant
22* .log
3+ backup
Original file line number Diff line number Diff line change @@ -30,12 +30,20 @@ The goal of this project is to create a quick virtual machine setup with a WordP
30305 . WordPress files are located in ` /var/www/html ` and you can run WPCli commands from there
31316 . This repo is mirrored from your local machine over to ` /quick-wordpress ` on your vm
3232
33+ ## Backup and Restores
34+ 1 . In order to do backup and restores login to your virtual machine - ` $ vagrant ssh `
35+ 2 . ` $ cd /quick-wordpress `
36+ 3 . ` $ ./backup.sh ` and follow the on screen instructions
37+ 4 . Backups are saved in the ` /quick-wordpress/backups ` directory
38+ 5 . If you'd like to restore from a previous backup - ` $ ./restore.sh ` and follow the on screen instructions
39+
3340## Cleanup
34411 . If you are ready to delete your WordPress VM from you local machine - ` $ vagrant destroy -f `
3542
3643## Project Roadmap
3744* ~~ LAMP Stack installed on Virtual Machine with WordPress using Vagrant~~
38- * Plugin installations on initial WordPress install
39- * Site Backups
40- * Site Restores
45+ * ~~ Plugin installations on initial WordPress install~~
46+ * ~~ Site Backups~~
47+ * ~~ Site Restores~~
48+ * Web Application instead of bash scripts for WordPress install, backup, and restore
4149* Modifications to WP details in order to give a working WordPress backup to a host
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ source /quick-wordpress/config
4+
5+ echo " ***************************** WordPress Backup **************************"
6+ run=true
7+ while $run
8+ do
9+ read -r -p " Would you like to name your backup? [Y/n] " input
10+
11+ case $input in
12+ [yY][eE][sS]|[yY])
13+ read -p " Enter the filename of your backup: " file
14+ backup_file=$file .tar.bz2
15+ echo " Will name backup $backup_file "
16+ run=false
17+ ;;
18+
19+ [nN][oO]|[nN])
20+ backup_file=$( date ' +%F_%s' ) .tar.bz2
21+ echo " Will name backup $backup_file "
22+ run=false
23+ ;;
24+
25+ * )
26+ echo " Invalid input..."
27+ ;;
28+ esac
29+ done
30+
31+ echo " ***************************** Backup Database ****************************"
32+ sudo mysqldump $wp_db > datadump.sql
33+
34+ echo " ***************************** Backups Files ******************************"
35+ mkdir -p /quick-wordpress/backup
36+ tar -cjvf /quick-wordpress/backup/$backup_file /var/www/html datadump.sql
37+
38+ echo " ***************************** Cleanup ************************************"
39+ rm datadump.sql
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ source /quick-wordpress/config
4+
5+ echo " ***************************** WordPress Restore **************************"
6+ read -p " Enter the filename of the backup you would like to restore: " file
7+
8+ backup_file=/quick-wordpress/backup/$file
9+
10+ if [ ! -f $backup_file ]; then
11+ echo " $backup_file not found!" 1>&2
12+ exit 1
13+ fi
14+
15+ echo " ***************************** Unpack Backup ******************************"
16+ mkdir -p /tmp/wp-bkup
17+ tar -xjvf $backup_file -C /tmp/wp-bkup
18+
19+ echo " ***************************** Nuke WP Installation ***********************"
20+ sudo rm -rf /var/www/html/*
21+
22+ echo " ***************************** Restore Files ******************************"
23+ sudo mv /tmp/wp-bkup/var/www/html/* /var/www/html/
24+
25+ echo " ***************************** Restore Database ***************************"
26+ sudo mysql $wp_db < /tmp/wp-bkup/datadump.sql
27+
28+ echo " ***************************** Cleanup ************************************"
29+ rm -rf /tmp/wp-bkup
You can’t perform that action at this time.
0 commit comments