dump script -------------------- -------------------- ---------- bin s

  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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
dump script:
--------------------------------------------------
#!/bin/sh
PREFIX=/usr/local/bin
VPSLIST=./VPSlist
VZPRIVATE=/var/lib/vz/private
VZCTL=/usr/sbin/vzctl
pushd $PREFIX
BWLIMIT=15000
RSYNC_CMD="rsync --timeout 600 -a --delete-after --numeric-ids --bwlimit $BWLIMIT --password-file=/etc/rsyncd.passwd"
RSYNC_CMD_FAST="rsync --timeout 600 --password-file=/etc/rsyncd.passwd -a --delete-after --numeric-ids"
HNS="hn1 hn2 hn3"
mkdir -p /var/lib/vz/conf
for HN in $HNS; do
VEIDS=`fgrep $HN $VPSLIST | grep -v ntp | awk -F\. '{print $1}' | sed 's,vps,,'`
for VEID in $VEIDS; do
rm -f /etc/vz/conf/$VEID.conf ||:
$RSYNC_CMD rsync://rsyncer@$HN::root/root/vz/private/$VEID/ $VZPRIVATE/$VEID
$RSYNC_CMD_FAST rsync://rsyncer@$HN::root/root/vz/private/$VEID/ $VZPRIVATE/$VEID
$RSYNC_CMD rsync://rsyncer@$HN::root/root/etc/vz/conf/$VEID.conf /var/lib/vz/conf/
cp /etc/vz/conf/ve-backup.sample.conf /etc/vz/conf/$VEID.conf
sleep 30s
done
sleep 1m
done
# check sql stuff
for HN in $HNS; do
VEIDS=`fgrep $HN $VPSLIST | grep -v ntp | awk -F\. '{print $1}' | sed 's,vps,,'`
# workflow :
# 1/ sync по HN
# 2/ sync всех конфигов в отдельное место
# 3/ подкладывание левых конфигов в /etc/vz/conf по VEID.
# 4/ запуск нужных контейнеров только с левым конфигом
for VEID in $VEIDS; do
if [ -d $VZPRIVATE/$VEID/var/lib/mysql/db ]; then
$VZCTL set $VEID --onboot no --save
chmod -x $VZPRIVATE/$VEID/etc/init.d/mysqld
$VZCTL start $VEID
$VZCTL exec $VEID myisamchk --silent --force --fast --update-state \
--key_buffer_size=64M --sort_buffer_size=64M \
--read_buffer_size=1M --write_buffer_size=1M \
--recover \
/var/lib/mysql/db/*/*.MYI
$VZCTL stop $VEID
chmod +x $VZPRIVATE/$VEID/etc/init.d/mysqld
fi
done
for VEID in $VEIDS; do
$VZCTL set $VEID --onboot no --save
done
done
popd
--------------------------------------------------
listvps:
--------------------------------------------------
#!/bin/sh
PREFIX=/usr/local/bin
pushd $PREFIX
HNS="hn1 hn2 hn3"
echo -n '' > VPSlist
for HN in $HNS; do
VPSES=`ssh -t $HN "vzlist -H -o hostname | tr -d ' ' | tr '\n' ' ' 2>/dev/null"`
for VPS in $VPSES; do
printf "%s %s\n" $VPS $HN >> VPSlist
done
done
popd
--------------------------------------------------
ve-backup.simple.conf:
--------------------------------------------------
# cat /etc/vz/conf/ve-backup.sample.conf
# resolver
VERSION="2"
ONBOOT="no"
# UBC parameters (in form of barrier:limit)
# Primary parameters
AVNUMPROC="8:8"
NUMPROC="1000:1000"
NUMTCPSOCK="10000:10000"
NUMOTHERSOCK="200:200"
VMGUARPAGES="6144:2147483647"
# Secondary parameters
KMEMSIZE="282144000:282144000"
TCPSNDBUF="327680000:532480000"
TCPRCVBUF="638976000:1048576000"
OTHERSOCKBUF="3276800:36044800"
DGRAMRCVBUF="1320960:1320960"
OOMGUARPAGES="6144:2147483647"
# Auxiliary parameters
LOCKEDPAGES="3200:3200"
SHMPAGES="12800000:12800000"
PRIVVMPAGES="41400000:41400000"
NUMFILE="40000:40000"
NUMFLOCK="500:500"
NUMPTY="1000:1000"
NUMSIGINFO="2560:2560"
DCACHESIZE="786432:25165440"
PHYSPAGES="0:2147483647"
NUMIPTENT="12800:12800"
# Disk quota parameters (in form of softlimit:hardlimit)
DISKSPACE="3460300800:3460300800"
DISKINODES="200000000:220000000"
QUOTATIME="0"
# CPU fair sheduler parameter
CPUUNITS="1000"
OFFLINE_MANAGEMENT="yes"
VE_ROOT="/var/lib/vz/root/$VEID"
VE_PRIVATE="/var/lib/vz/private/$VEID"
# OSTEMPLATE="altlinux-2.4"
ORIGIN_SAMPLE="resolver"
IP_ADDRESS="172.13.6.66"
HOSTNAME="backup.tld"