Révision 42f1f46f
Ajouté par Julien Enselme il y a environ 10 ans
bin/d7-sync-site.sh | ||
---|---|---|
16 | 16 |
|
17 | 17 |
check_arguments $# 2 "$help" |
18 | 18 |
|
19 |
|
|
19 | 20 |
# Create site if necessary |
20 | 21 |
if ! site_exists $2 > /dev/null ; then |
21 | 22 |
echo "$2 does not exit. We will create it" |
... | ... | |
24 | 25 |
new_site=1 |
25 | 26 |
fi |
26 | 27 |
|
28 |
|
|
27 | 29 |
# Backup the database of SOURCE_SITE |
28 | 30 |
current_date=$(date "+%Y-%m-%d-%Hh%Mm%Ss") |
29 | 31 |
if [ $1 = "default" ] ; then |
... | ... | |
35 | 37 |
drush -y @$1 sql-dump --result-file=$d7_dir_individual_manual_backup/$dir/$current_date.$dir.sql --gzip |
36 | 38 |
fi |
37 | 39 |
|
40 |
|
|
38 | 41 |
# Sync files |
39 | 42 |
drush -y rsync --delete --exclude="*.php" @${1}:%site @${2}:%site |
40 | 43 |
|
44 |
|
|
41 | 45 |
# Sync databases |
42 | 46 |
## Save file system |
43 | 47 |
if [ -z "$new_site" ] ; then |
... | ... | |
45 | 49 |
public_path=$(drush @$2 vget --format=string file_public_path 2> /dev/null) |
46 | 50 |
temp_path=$(drush @$2 vget --format=string file_temporary_path 2> /dev/null) |
47 | 51 |
fi |
52 |
|
|
48 | 53 |
## Sync |
49 | 54 |
current_date=$(date "+%Y-%m-%d-%Hh%Mm%Ss") |
50 | 55 |
sql_file=$dir_tmp/$current_date.$1.sql |
51 | 56 |
drush -y @$1 sql-dump --result-file=$sql_file |
52 | 57 |
sed -i -e "s#https?://assos.centrale-marseille.fr/$1#https://assos.centrale-marseille.fr/$2#g" $sql_file |
53 |
drush -y @$2 sql-sync --create-db --source-dump $sql_file |
|
58 |
mysql --defaults-extra-file=$myassos_cnf -e "DROP DATABASE IF EXISTS $2; CREATE DATABASE $2" |
|
59 |
mysql --defaults-extra-file=$myassos_cnf $2 < $sql_file |
|
54 | 60 |
rm $sql_file |
61 |
|
|
55 | 62 |
## Restore file system |
56 | 63 |
if [ -n "$private_path" ] ; then |
57 | 64 |
drush -y @$2 vset file_private_path $private_path |
Formats disponibles : Unified diff
Use mysql to sync database instead of drush sql-sync.