File: dtc_migrate

package info (click to toggle)
dtc 0.35.5-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 18,824 kB
  • sloc: php: 50,739; sh: 8,596; makefile: 572; perl: 148; xml: 25
file content (84 lines) | stat: -rwxr-xr-x 2,318 bytes parent folder | download
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
#!/bin/sh

set -e

DTC_PATH=/usr/share/dtc

# Basic check of paramteres
usages () {
	echo "dtc_migrate [-d] <DESTINATION_SERVER>"
	echo "The -d flag does a rsync with the --delete option"
	echo "when uploading /var/www/sites"
	exit 1
}
if [ $# = 2 ] ; then
	if ! [ ${1} = "-d" ] ; then
		usages
	fi
	RSYNCOPT="--delete"
	DST=${2}
else
	if [ $# -lt 1 ]; then
		usages
	fi
	if [ $# -gt 1 ]; then
		usages
	fi
	RSYNCOPT=""
	DST=${1}
fi

echo "===> DTC Migrate script: upload of all DBs"
echo -n "Getting local IP: "
my_ip=`${DTC_PATH}/admin/guess_ip.sh`
echo ${my_ip}

scp ${DTC_PATH}/admin/guess_ip.sh ${DST}:${DTC_PATH}/admin/
echo -n "Getting remote IP: "
rem_ip=`ssh ${DST} ${DTC_PATH}/admin/guess_ip.sh`
echo ${rem_ip}

if [ -f /etc/redhat-release ] ; then
	MKTEMP="mktemp -p /tmp"
else
	MKTEMP="mktemp -t"
fi

bk_dir=`${MKTEMP} -d DTC_migrate.XXXXXX`
echo "Will backup in ${bk_dir}"

echo -n "Will import in "
rem_dir=`ssh ${DST} "${MKTEMP} -d DTC_migrate.XXXXXX"`
echo ${rem_dir}

php migrate_to_server.php ${bk_dir} ${my_ip} ${rem_ip}
sed -i "s/${my_ip}/${rem_ip}/g" ${bk_dir}/dtc.sql

echo "Copying SQL files to remote:"
scp ${bk_dir}/*.sql ${DTC_PATH}/admin/dtc_import_all_dbs $DST:$rem_dir

echo "Starting the dtc_import_all_dbs script on remote:"
ssh ${DST} ${rem_dir}/dtc_import_all_dbs ${rem_dir}

echo -n "Cleaning temp folders on: "
echo -n "local server"
rm -rf ${bk_dir}
echo -n ", remote server"
ssh ${DST} rm -rf ${rem_dir}
echo "done"

echo "===> DTC Migrate script: upload of all files"
cd /var/www/sites
EXCLUDE=""
for i in */*/subdomains.aufs ; do EXCLUDE="${EXCLUDE} --exclude $i" ; done
echo "rsync -e ssh -azvp ${RSYNCOPT} /var/www/sites/ ${DST}:/var/www/sites (excluding subdomains.aufs folders)"
nice rsync ${EXCLUDE} -e ssh -azvp ${RSYNCOPT} /var/www/sites/ ${DST}:/var/www/sites || true
echo "rsync of the MLMMJ and /etc/dtc folders"
nice rsync -e ssh -azvp ${RSYNCOPT} /etc/mlmmj/ ${DST}:/etc/mlmmj
nice rsync -e ssh -azvp /etc/dtc/ ${DST}:/etc/dtc
# copy the rrd files over too
nice rsync -e ssh -azvp /var/lib/dtc/etc/*.rrd ${DST}:/var/lib/dtc/etc
# copy the squirrelmail prefs and address book
nice rsync -e  ssh -azvp /var/lib/squirrelmail/data/ ${DST}:/var/lib/squirrelmail/data
echo "===> Starting the DTC installer script on the remote"
ssh ${DST} ${DTC_PATH}/admin/install/install