forked from infinum/eightshift-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_db-import-production-to-dev.sh
45 lines (34 loc) · 1.1 KB
/
_db-import-production-to-dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env sh
# Prettyfiers
BLUE='\033[0;36m'
RED='\033[0;31m'
BBLUE="\033[1;36m"
NC='\033[0m' # No Color
# Check if dump exists
if [ ! -f "latest_dump.tar.gz" ]; then
echo "${RED}Fail! File latest_dump.tar.gz doesn't exist!${NC}"
exit 1
fi
# Remove temp folder
rm -rf latest_dump
# Create temp folder
if [ ! -d "latest_dump" ]; then
echo "${BLUE}Creating temp latest_dump folder!${NC}"
mkdir latest_dump
fi
tar zxf latest_dump.tar.gz -C latest_dump
echo "${BLUE}Exporting folders success!${NC}"
# Clear the database of all tables
wp db reset
# Import database
echo "${BLUE}Database import and search replace in progress...${NC}"
wp db import latest_dump/db_dump/latest.sql
# Search and replace for URL
wp search-replace www.boilerplate.com dev.boilerplate.com --url=www.boilerplate.com --all-tables
# Search and replace for https to http
wp search-replace https://dev.boilerplate.com http://dev.boilerplate.com --all-tables
echo "${BLUE}Flushing cache, removing transients and resetting premalinks!${NC}"
wp cache flush
wp transient delete --all
wp rewrite flush
echo "${BBLUE}Finished! Success!${NC}"