mirror of
https://github.com/myvesta/vesta.git
synced 2024-12-21 11:31:21 -08:00
54 lines
1.5 KiB
Bash
Executable File
54 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: delete user backup
|
|
# options: USER BACKUP
|
|
#
|
|
# The function deletes user backup.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
user=$1
|
|
backup=$(echo $2| cut -f 2 -d \.)
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '2' "$#" 'USER BACKUP'
|
|
is_format_valid 'user' 'backup'
|
|
is_system_enabled "$BACKUP_SYSTEM" 'BACKUP_SYSTEM'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
is_object_unsuspended 'user' 'USER' "$user"
|
|
is_object_valid 'backup' 'BACKUP' "$2"
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Deleting backup
|
|
rm -f $BACKUP/$2
|
|
sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Update counter
|
|
U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l)
|
|
update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
|
|
|
|
# Logging
|
|
log_history "deleted backup archive $backup"
|
|
log_event "$OK" "$ARGUMENTS"
|
|
|
|
exit
|