-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssdownload.sh
executable file
·93 lines (73 loc) · 2.02 KB
/
ssdownload.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
#
# Script to download SilverStripe assets & DB from server
#
# Usage:
# download-changes USERNAME REMOTEHOST
# download-changes naco slate
start=`date +%s`
# Display current date & time for starting reference
date
# Load from site config file
#
# EXAMPLE ssdownload.conf
# REMOTEHOST=example.com
# USERNAME=example
# REMOTESITEROOT=public_html
#
FILE=ssdownload.conf
if test -f "$FILE"; then
source $FILE
else
# Get values as arguments
USERNAME=$1
REMOTEHOST=$2
REMOTESITEROOT=${3:-/home/$USERNAME/public_html}
fi
if test -f "_ss_environment.php" ; then
echo ' '
echo '=================================='
echo '** Syncing SS3 Assets:'
echo '=================================='
rsync --delete -av -e ssh $USERNAME@$REMOTEHOST:$REMOTESITEROOT/assets/ ./assets/
fi
if test -f ".env" ; then
echo ' '
echo '=================================='
echo '** Syncing SS4 Assets:'
echo '=================================='
rsync --delete -av -e ssh $USERNAME@$REMOTEHOST:$REMOTESITEROOT/public/assets/ ./public/assets/
fi
echo ' '
echo '=================================='
echo '** Removing Any Existing SSPak File:'
echo '=================================='
rm download.sspak
sleep 0.2s
echo ' '
echo '=============================='
echo '** Exporting DB to SSPak File:'
echo '=============================='
sspak save --db $USERNAME@$REMOTEHOST:$REMOTESITEROOT download.sspak
sleep 0.2s
echo ' '
echo '================================'
echo '** Importing DB from SSPak File:'
echo '================================'
sspak load --db download.sspak . --drop-db
sleep 0.2s
echo ' '
echo '========================'
echo '** Removing SSPak File:'
echo '========================'
rm download.sspak
sleep 0.2s
echo ' '
echo '========================'
echo '** Performing dev/build:'
echo '========================'
valet php vendor/silverstripe/framework/cli-script.php dev/build flush=1
# Output time taken
echo ' '
echo "$USERNAME - Done in $((($(date +%s)-$start)/60)) minutes ($((($(date +%s)-$start))) secs)"
echo ' '