Skip to content

Commit 7ba0758

Browse files
committed
added upd backup function
1 parent add6ebe commit 7ba0758

File tree

3 files changed

+320
-37
lines changed

3 files changed

+320
-37
lines changed

bin/v_backup_sys_user

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ fi
7878
# Addding backup and vesta version
7979
echo "1.0" > $tmpdir/backup_version
8080
echo "$VERSION" > $tmpdir/vesta_version
81+
vst='yes'
8182

8283
# Vesta
8384
if [ -z "$output" ]; then
@@ -205,14 +206,14 @@ then
205206
echo -e "\t$(date +%H:%M:%S) $domain"
206207
fi
207208

209+
# Building directory tree
210+
mkdir -p $tmpdir/web/$domain/conf
211+
mkdir -p $tmpdir/web/$domain/ssl
212+
208213
# Defining domain variables
209214
domain_idn=$(idn -t --quiet -a "$domain")
210-
tpl_name=$(get_web_domain_value '$TPL')
211-
ssl_cert=$(get_web_domain_value '$SSL_CERT')
212-
nginx=$(get_web_domain_value '$NGINX')
215+
get_web_domain_values
213216

214-
# Building directory tree
215-
mkdir -p $tmpdir/web/$domain/conf $tmpdir/web/$domain/cert
216217

217218
# Packing data folders
218219
cd $V_HOME/$user/web/$domain
@@ -227,30 +228,30 @@ then
227228
# Apache config
228229
if [ "$WEB_SYSTEM" = 'apache' ]; then
229230
# Parsing httpd.conf
230-
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
231+
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
231232
conf="$V_HOME/$user/conf/httpd.conf"
232233
get_web_config_brds
233234
sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf
234235

235236
# SSL check
236-
if [ ! -z "$ssl_cert" ]; then
237-
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
237+
if [ ! -z "$SSL" ]; then
238+
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
238239
conf="$V_HOME/$user/conf/shttpd.conf"
239240
get_web_config_brds
240241
sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf
241242
fi
242243
fi
243244

244245
# Nginx config
245-
if [ ! -z "$nginx" ] ; then
246-
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
246+
if [ ! -z "$NGINX" ] ; then
247+
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
247248
conf="$V_HOME/$user/conf/nginx.conf"
248249
get_web_config_brds
249250
sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf
250251

251252
# SSL check
252-
if [ ! -z "$ssl_cert" ] ; then
253-
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl"
253+
if [ ! -z "$SSL" ] ; then
254+
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
254255
conf="$V_HOME/$user/conf/snginx.conf"
255256
get_web_config_brds
256257
sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf
@@ -263,11 +264,11 @@ then
263264
done
264265

265266
# SSL Certificates
266-
if [ ! -z "$ssl_cert" ] ; then
267-
cp $V_HOME/$user/conf/$ssl_cert.* cert/
267+
if [ ! -z "$SSL" ] ; then
268+
cp $V_HOME/$user/conf/$SSL.* ssl/
268269
fi
269270

270-
tar -rf $tmpdir/web/$domain/$domain.tar conf cert
271+
tar -rf $tmpdir/web/$domain/$domain.tar conf ssl
271272
mv $tmpdir/web/$domain/$domain.tar $tmpdir/web/
272273
rm -rf $tmpdir/web/$domain
273274

@@ -319,7 +320,7 @@ then
319320
grep "DOMAIN='$domain'" $conf > dns.conf
320321

321322
# Backingup dns recods
322-
cp $V_USERS/$user/zones/$domain $domain
323+
cp $V_USERS/$user/dns/$domain $domain
323324
cp /etc/namedb/$domain.db $domain.db
324325
done
325326

@@ -379,7 +380,6 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then
379380
if [ -z "$output" ]; then
380381
echo
381382
fi
382-
383383
fi
384384

385385
# Cron jobs
@@ -414,20 +414,20 @@ fi
414414
# SSL CERTIFICATES
415415
if [ ! -z "$WEB_SSL" ] && [ "$WEB_SSL" != 'no' ] && [ "$SSL" != '*' ]; then
416416
if [ -z "$output" ]; then
417-
echo "-- CERTIFICATES --"
417+
echo "-- SSL --"
418418
fi
419-
mkdir $tmpdir/cert
419+
mkdir $tmpdir/ssl
420420

421421
# Backingup ssl certificates
422-
cert_list=$(ls $V_USERS/$user/cert/ | grep ".crt" |\
422+
cert_list=$(ls $V_USERS/$user/ssl/ | grep ".crt" |\
423423
sed -e "s/\.crt$//" |\
424424
tr '\n' ' ' |\
425425
sed -e 's/ $//' )
426426
for cert in $cert_list; do
427427
if [ -z "$output" ]; then
428428
echo -e "\t$(date +%H:%M:%S) $cert"
429429
fi
430-
cp $V_USERS/$user/cert/$cert.* $tmpdir/cert/
430+
cp $V_USERS/$user/ssl/$cert.* $tmpdir/ssl/
431431
done
432432

433433
if [ -z "$output" ]; then
@@ -500,7 +500,7 @@ local_backup(){
500500
# Defining ftp command function
501501
ftpc() {
502502
ftp -n $HOST $PORT <<EOF
503-
quote USER $USER
503+
quote USER $USERNAME
504504
quote PASS $PASSWORD
505505
binary
506506
cd $BPATH
@@ -516,24 +516,18 @@ ftp_backup(){
516516
fi
517517

518518
# Checking config
519-
if [ -e "$V_CONF/backup.conf" ]; then
520-
ftphost_str=$(grep "TYPE='FTP'" $V_CONF/backup.conf |head -n 1)
521-
fi
522-
523-
# Parsing config values
524-
if [ ! -z "$ftphost_str" ]; then
525-
for key in $ftphost_str; do
526-
eval ${key%%=*}=${key#*=}
527-
done
528-
else
519+
source $V_CONF/ftp.backup.conf
520+
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
521+
[ -z "$BPATH" ]; then
529522
echo "Error: Parsing error"
530523
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
531524
exit $E_PARSE_ERROR
532525
fi
533526

534527
# Debug info
535528
if [ -z "$output" ]; then
536-
echo -e "\t$(date +%H:%M:%S) ftp://$USER@$HOST$BPATH/$user.$V_DATE.tar"
529+
echo -ne "\t$(date +%H:%M:%S) "
530+
echo -e "ftp://$USERNAME@$HOST$BPATH/$user.$V_DATE.tar"
537531
fi
538532

539533
# Checking ftp permission
@@ -592,7 +586,7 @@ done
592586
cd /
593587
rm -rf $tmpdir
594588

595-
# Calcilation run time
589+
# Calculation run time
596590
run_time=$((end_time - start_time))
597591
run_time=$((run_time / 60))
598592
current_time=$(date +'%H:%M:%S')
@@ -626,11 +620,12 @@ done
626620
# Concatenating string
627621
backup_str="DATE='$V_DATE' TIME='$current_time' RUNTIME='$run_time'"
628622
backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
623+
backup_str="$backup_str VESTA='$vst'"
629624
backup_str="$backup_str WEB='${web_list// /,}'"
630625
backup_str="$backup_str DNS='${dns_list// /,}'"
631626
backup_str="$backup_str MAIL='${mail_list// /,}'"
632627
backup_str="$backup_str DB='${db_list// /,}'"
633-
backup_str="$backup_str CERTIFICATES='${cert_list// /,}'"
628+
backup_str="$backup_str SSL='${cert_list// /,}'"
634629
backup_str="$backup_str CRON='$cron_list'"
635630
echo "$backup_str" >> $V_USERS/$user/backup.conf
636631

bin/v_list_sys_user_backups

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,22 @@ is_user_valid
3030
#----------------------------------------------------------#
3131
# Action #
3232
#----------------------------------------------------------#
33+
34+
# Checking config
3335
conf=$V_USERS/$user/backup.conf
3436
if [ ! -e "$conf" ]; then
3537
touch $conf
3638
fi
3739

3840
# Defining fileds to select
39-
fields="\$DATE \$TIME \$RUNTIME \$TYPE \$SIZE \$WEB \$DNS \$DB \$MAIL"
41+
fields="\$DATE \$TIME \$RUNTIME \$TYPE \$SIZE \$VESTA \$WEB \$DNS \$DB \$MAIL"
4042
fields="$fields \$CERTIFICATES \$CRON"
4143

4244
# Listing domains
4345
case $format in
4446
json) json_list ;;
4547
plain) nohead=1; shell_list ;;
46-
shell) fields='$DATE $TIME $RUNTIME $TYPE $SIZE';shell_list |column -t ;;
48+
shell) fields='$DATE $TIME $RUNTIME $TYPE $SIZE'; shell_list |column -t;;
4749
*) check_args '1' '0' '[format]' ;;
4850
esac
4951

0 commit comments

Comments
 (0)