1
0
mirror of https://github.com/serghey-rodin/vesta.git synced 2025-03-12 04:36:25 -07:00
vesta/bin/v-update-user-backup-exclusions

79 lines
2.0 KiB
Plaintext
Raw Normal View History

2014-04-07 23:40:37 +03:00
#!/bin/bash
# info: update backup exclusion list
# options: USER FILE
#
# The function for updating backup exclusion list
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2014-04-07 23:40:37 +03:00
user=$1
vfile=$2
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
is_file_available() {
if [ ! -e "$vfile" ]; then
check_result $E_NOTEXIST "file $vfile doesn't exist"
2014-04-07 23:40:37 +03:00
fi
}
is_file_valid() {
2016-06-25 11:09:44 +03:00
exclude="[!|#|$|^|&|(|)|{|}|<|>|?|\|\"|;|%|\`]"
if [[ "$(cat $vfile)" =~ $exclude ]]; then
check_result $E_INVALID "invalid characters in the exlusion list"
2014-04-07 23:40:37 +03:00
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER FILE'
is_format_valid 'user' 'vfile'
2014-04-07 23:40:37 +03:00
is_object_valid 'user' 'USER' "$user"
is_file_available
is_file_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Flush variables
WEB=''
DNS=''
MAIL=''
DB=''
CRON=''
USER=''
# Source exclusion list
source $vfile
# Updating exlusion list
echo "WEB='$WEB'" > $USER_DATA/backup-excludes.conf
echo "DNS='$DNS'" >> $USER_DATA/backup-excludes.conf
echo "MAIL='$MAIL'" >> $USER_DATA/backup-excludes.conf
echo "DB='$DB'" >> $USER_DATA/backup-excludes.conf
2014-07-06 16:05:14 +03:00
echo "CRON='$CRON'" >> $USER_DATA/backup-excludes.conf
2014-04-07 23:40:37 +03:00
echo "USER='$USER'" >> $USER_DATA/backup-excludes.conf
chmod 660 $USER_DATA/backup-excludes.conf
2014-04-07 23:40:37 +03:00
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_history "updated exlusion list"
log_event "$OK" "$ARGUMENTS"
2014-04-07 23:40:37 +03:00
exit