chocolatdemariage/synchro.sh
Michael RICOIS 13af38bf11 Add synchro
2017-07-27 17:39:01 +02:00

29 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
clear
## NO MORE DB UPDATES ON THE PREPROD ##
#Dump local database
echo "Exporting the local Database"
mysqldump -h 192.168.0.41 -u root chocolatdemariage > chocolatdemariage.sql
printf "Export complete => file chocolatdemariage.sql has been created\n"
printf "Replacing shop names\n"
sed -i -e 's/chocolatdemariage.local/chocolatdemariage.preprod.antadis.fr/g' chocolatdemariage.sql
printf "Sending the Database dump to the preprod server"
PORT="4096"
rsync -e "ssh -p$PORT" -az ./chocolatdemariage.sql root@chocolatdemariage.preprod.antadis.fr:/home/www/chocolatdemariage.preprod.antadis.fr
printf "Sending complete\n"
#printf "importing the Database on the preprod server\n"
ssh root@chocolatdemariage.preprod.antadis.fr -p4096 "cd /home/www/chocolatdemariage.preprod.antadis.fr \\
&& git pull origin master \\
&& mysql -u chocolatdemariage -pantadis78 chocolatdemariage < chocolatdemariage.sql \\
&& if [ -f /home/www/chocolatdemariage.preprod.antadis.fr/www/cache/class_index.php ] ; then rm /home/www/chocolatdemariage.preprod.antadis.fr/www/cache/class_index.php ; fi \\
&& mkdir -p /home/www/chocolatdemariage.preprod.antadis.fr/www/{log,upload} \\
&& chown -R www-data:www-data www/* \\
"
printf "Sync complete !! \n"