This repository has been archived by the owner on Apr 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
export.sh
68 lines (52 loc) · 1.65 KB
/
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
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
#!/bin/bash
#
# Script d'expoort de BDD distante
# Accès SSH nécesaire
#
# Config
#
vhost_local='http://localhost/project'
projet_local_folder='h:/www/project'
prefix_local=''
vhost_dist='http://preprod.project.com'
project_dist_folder='~/www/preprod/project'
prefix_dist=''
d=$(date +%Y-%m-%d_%Hh-%Mm-%Ss)
export_dist_folder='tmp'
export_file_name='export-local-'$d'.sql'
ssh_info='user@domain.com'
script_dir='h:/www/_lab/import-export/project'
#
# Process
#
cd $projet_local_folder
pwd
echo "Export de la bdd locale"
php C:/wp-cli/wp-cli.phar search-replace $vhost_local $vhost_dist --export=$export_file_name
echo "--------------------------------------"
echo "On change les prefixes"
sed -i "s/${prefix_local}/${prefix_dist}/g" $export_file_name
echo "--------------------------------------"
echo "On copie le fichier sql dans le dossier du script"
cp $export_file_name $script_dir
echo "--------------------------------------"
echo "Suppression du fichier .sql dans le dossier du projet"
rm -f $export_file_name
echo "--------------------------------------"
echo "Copie du fichier sql sur le serveur distant"
cd $script_dir
scp $export_file_name $ssh_info:$project_dist_folder
echo "--------------------------------------"
ssh $ssh_info "
echo "On se positione dans le dossier du projet sur le serveur distant"
cd $project_dist_folder
echo "--------------------------------------"
echo "On importe la base locale sur le serveur distant"
wp db import $export_file_name
echo "--------------------------------------"
echo "Suppression du fichier .sql sur le serveur distant"
rm -f $export_file_name
echo "--------------------------------------"
exit
"
exit