forked from infinum/eightshift-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_db-export.sh
41 lines (33 loc) · 994 Bytes
/
_db-export.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
#!/usr/bin/env sh
# Prettyfiers
BLUE='\033[0;36m'
RED='\033[0;31m'
BBLUE="\033[1;36m"
NC='\033[0m' # No Color
# Create temp folder
if [ ! -d "db_dump" ]; then
echo -e "${BLUE}Creating temp db_dump folder!${NC}"
mkdir db_dump
fi
# Export latest db
wp db export db_dump/latest.sql
echo -e "${BLUE}Exporting db to db_dump/latest.sql${NC}"
# Remove old dump
if [ -f "latest_dump.tar.gz" ]; then
echo -e "${BLUE}Removing old compressed latest.tar.gz file!${NC}"
rm latest_dump.tar.gz
fi
# Exit if folders are not existing
if [ ! -d "db_dump" ] || [ ! -d "wp-content/uploads/" ]; then
echo -e "${RED}Fail! Folders are missing!${NC}"
exit 1
fi
# Compress folders
tar czf latest_dump.tar.gz db_dump/ wp-content/uploads/
echo -e "${BLUE}Compressing folders success!${NC}"
# Remove temp folder
if [ -d "db_dump" ]; then
rm -rf db_dump
echo -e "${BLUE}Removing temp db_dump folder!${NC}"
fi
echo -e "${BBLUE}Export complete! File is located in root folder latest_dump.tar.gz${NC}"