Project

General

Profile

Paste
Download (1.32 KB) Statistics
| Branch: | Revision:

root / other-scripts / d7-sync.sh @ ef903da4

1
#!/usr/bin/bash
2

    
3
help=<<EOF
4
This script is intended to ease the synchronisation of any site hosted by assos. It relies on bash, drush and requires @ssh assos@ to work.
5
The drupal installation is synched using git, the website files and database using rsync.
6

    
7
usage: d7-sync.sh [SITENAME]
8
If a sitename is provided, the script will sync the drupal installation and the sites'
9
folders and database. Othewise, only the drupal installation is synched.
10

    
11
You must launch this script at the root of the drupal instance.
12
EOF
13

    
14
# sync drupal tree
15
git pull --rebase
16

    
17
# sync files
18
if [ -z "$1" ] ; then
19
    exit 0
20
fi
21

    
22
root=$(pwd)
23
cd htmltest/sites
24
if [ $1 = default ] ; then
25
    dir_site=$1
26
else
27
    dir_site=assos.centrale-marseille.fr.$1
28
fi
29
mkdir $dir_site
30
cd $dir_site
31
rsync -rl --progress assos:~/htmltest/sites/$dir_site/* .
32

    
33
# sync databases
34
now=$(date +%s)
35
sql_file="$1.$now.sql"
36
remote_sql_file="~/tmp/$sql_file"
37
ssh assos "drush @$1 sql-dump > $remote_sql_file"
38
scp assos:$remote_sql_file .
39
mysql -u root -e "DROP DATABASE IF EXISTS $1; CREATE DATABASE $1"
40
mysql -u root $1 < $sql_file
41
rm $sql_file
42
ssh assos "rm $remote_sql_file"
43

    
44
# modify settings.php
45
python3 $root/other-scripts/modify-settings.py settings.local.php
46

    
47
# various drush cmd to finish synchronisation
48
drush -y dis piwik
49
drush -y vset maintenace_mode 0
50
drush -y vset error_level 2
51
drush cc all