mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-19 13:01:51 -07:00
Fix for better backup.conf cleaning
This commit is contained in:
parent
253e28ede2
commit
df789310fb
1 changed files with 12 additions and 17 deletions
|
@ -536,11 +536,8 @@ TIME=$(date +%T)
|
||||||
|
|
||||||
# Defining local storage function
|
# Defining local storage function
|
||||||
local_backup(){
|
local_backup(){
|
||||||
# Removing dublicate for this day
|
|
||||||
if [ -e "$BACKUP/$user.$DATE.tar" ]; then
|
|
||||||
deprecated="$DATE"
|
|
||||||
rm -f $BACKUP/$user.$DATE.tar
|
rm -f $BACKUP/$user.$DATE.tar
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking retention
|
# Checking retention
|
||||||
backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.")
|
backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.")
|
||||||
|
@ -549,10 +546,9 @@ local_backup(){
|
||||||
backups_rm_number=$((backups_count - BACKUPS))
|
backups_rm_number=$((backups_count - BACKUPS))
|
||||||
(( ++backups_rm_number))
|
(( ++backups_rm_number))
|
||||||
|
|
||||||
for backup in $(echo "$backup_list" | head -n $backups_rm_number); do
|
|
||||||
# Removing old backup
|
# Removing old backup
|
||||||
|
for backup in $(echo "$backup_list" | head -n $backups_rm_number); do
|
||||||
backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//")
|
backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//")
|
||||||
deprecated="$deprecated $backup_date"
|
|
||||||
echo -e "$(date "+%F %T") Roated: $backup_date"
|
echo -e "$(date "+%F %T") Roated: $backup_date"
|
||||||
msg="$msg\n$(date "+%F %T") Rotated: $backup_date"
|
msg="$msg\n$(date "+%F %T") Rotated: $backup_date"
|
||||||
rm -f $BACKUP/$backup
|
rm -f $BACKUP/$backup
|
||||||
|
@ -672,7 +668,6 @@ ftp_backup() {
|
||||||
backups_rm_number=$((backups_count - BACKUPS + 1))
|
backups_rm_number=$((backups_count - BACKUPS + 1))
|
||||||
for backup in $(echo "$backup_list" | head -n $backups_rm_number); do
|
for backup in $(echo "$backup_list" | head -n $backups_rm_number); do
|
||||||
backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//")
|
backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//")
|
||||||
deprecated="$deprecated $backup"
|
|
||||||
echo -e "$(date "+%F %T") Roated ftp backup: $backup_date"
|
echo -e "$(date "+%F %T") Roated ftp backup: $backup_date"
|
||||||
msg="$msg\n$(date "+%F %T") Roated ftp backup: $backup_date"
|
msg="$msg\n$(date "+%F %T") Roated ftp backup: $backup_date"
|
||||||
ftpc "cd $BPATH" "delete $backup"
|
ftpc "cd $BPATH" "delete $backup"
|
||||||
|
@ -704,7 +699,6 @@ for backup_type in $(echo -e "${BACKUP_SYSTEM//,/\\n}"); do
|
||||||
done
|
done
|
||||||
|
|
||||||
# Removing tmpdir
|
# Removing tmpdir
|
||||||
cd /
|
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
|
|
||||||
# Calculation run time
|
# Calculation run time
|
||||||
|
@ -729,14 +723,11 @@ msg="$msg\n$(date "+%F %T") Runtime: $run_time $min"
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Deleting old backup records
|
# Removing duplicate
|
||||||
for backup_record in $deprecated; do
|
touch $USER_DATA/backup.conf
|
||||||
if [ -e "$USER_DATA/backup.conf" ]; then
|
sed -i "/$user.$DATE.tar/d" $USER_DATA/backup.conf
|
||||||
sed -i "/DATE='$backup_record/d" $USER_DATA/backup.conf
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Concatenating string
|
# Regestering new backup
|
||||||
backup_str="BACKUP='$user.$DATE.tar'"
|
backup_str="BACKUP='$user.$DATE.tar'"
|
||||||
backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
|
backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
|
||||||
backup_str="$backup_str WEB='${web_list// /,}'"
|
backup_str="$backup_str WEB='${web_list// /,}'"
|
||||||
|
@ -747,9 +738,13 @@ backup_str="$backup_str CRON='$cron_list'"
|
||||||
backup_str="$backup_str UDIR='${udir_list// /,}'"
|
backup_str="$backup_str UDIR='${udir_list// /,}'"
|
||||||
backup_str="$backup_str RUNTIME='$run_time' TIME='$TIME' DATE='$DATE'"
|
backup_str="$backup_str RUNTIME='$run_time' TIME='$TIME' DATE='$DATE'"
|
||||||
echo "$backup_str" >> $USER_DATA/backup.conf
|
echo "$backup_str" >> $USER_DATA/backup.conf
|
||||||
|
|
||||||
|
# Removing old backups
|
||||||
|
tail -n $BACKUPS $USER_DATA/backup.conf > $USER_DATA/backup.conf_
|
||||||
|
mv -f $USER_DATA/backup.conf_ $USER_DATA/backup.conf
|
||||||
chmod 660 $USER_DATA/backup.conf
|
chmod 660 $USER_DATA/backup.conf
|
||||||
|
|
||||||
# Clean backup queue
|
# Deleting task from queue
|
||||||
sed -i "/v-backup-user $user /d" $VESTA/data/queue/backup.pipe
|
sed -i "/v-backup-user $user /d" $VESTA/data/queue/backup.pipe
|
||||||
|
|
||||||
# Send notification
|
# Send notification
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue