Skip to content

Commit c72a592

Browse files
committed
started to work on backups
1 parent 5ad5853 commit c72a592

File tree

2 files changed

+98
-1
lines changed

2 files changed

+98
-1
lines changed

bin/v_backup_sys_user

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
# info: backup system user with all its objects
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
# Argument defenition
9+
user="$1"
10+
11+
# Importing variables
12+
source $VESTA/conf/vars.conf
13+
source $V_FUNC/shared_func.sh
14+
source $V_FUNC/domain_func.sh
15+
source $V_FUNC/db_func.sh
16+
source $V_CONF/vesta.conf
17+
18+
19+
#----------------------------------------------------------#
20+
# Verifications #
21+
#----------------------------------------------------------#
22+
23+
# Checking arg number
24+
check_args '1' "$#" 'user'
25+
26+
# Checking argument format
27+
format_validation 'user'
28+
29+
# Checking user
30+
is_user_valid
31+
32+
33+
#----------------------------------------------------------#
34+
# Action #
35+
#----------------------------------------------------------#
36+
37+
# Creating temporary random directory
38+
tmpdir=$(mktemp -p $V_TMP -d)
39+
echo "TMPDIR is $tmpdir"
40+
# Web domains
41+
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
42+
mkdir $tmpdir/web/
43+
44+
# Parsing unsuspeneded domains
45+
conf="$V_USERS/$user/web_domains.conf"
46+
field='$DOMAIN'
47+
search_string='DOMAIN='
48+
domains=$(dom_clear_search)
49+
50+
for domain in $domains; do
51+
echo $domain
52+
53+
# backup_domain
54+
mkdir -p $tmpdir/web/$domain/conf $tmpdir/web/$domain/cert
55+
56+
# Packing data folders
57+
cd $V_HOME/$user/web/$domain
58+
tar -cf $tmpdir/web/$domain/$domain.tar \
59+
public_html public_shtml private document_errors cgi-bin stats
60+
61+
# Creating config folder
62+
cd $tmpdir/web/$domain/
63+
grep "DOMAIN='$domain'" $conf > conf/web_domains.conf
64+
65+
# Parsing httpd.conf
66+
tpl_name=$(get_web_domain_value '$TPL')
67+
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
68+
conf="$V_HOME/$user/conf/httpd.conf"
69+
70+
71+
# Parsing nginx.conf
72+
73+
done
74+
fi
75+
76+
exit
77+
78+
# DNS domains
79+
80+
# Mail domains
81+
82+
# DatbaBases
83+
84+
# Cron jobs
85+
86+
# Vesta
87+
88+
89+
#----------------------------------------------------------#
90+
# Vesta #
91+
#----------------------------------------------------------#
92+
93+
94+
# Logging
95+
log_event 'system' "$V_EVENT"
96+
97+
exit $OK

conf/vars.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ V_IPS="$V_DATA/ips"
2020
V_WEBTPL="$V_DATA/templates"
2121
V_DNSTPL="$V_WEBTPL/dns"
2222
V_LOCK=/var/lock/vesta
23-
V_EXE="$VESTA_BIN/vesta"
2423
V_HOME='/home'
2524
V_TMP='/tmp'
25+
V_BACKUP='/backup'
2626

2727
# Other vars
2828
V_SUSPEND_URL='vestacp.com/faq/acc_suspended/'

0 commit comments

Comments
 (0)