|
| 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 |
0 commit comments