diff --git a/bin/v_backup_sys_user b/bin/v_backup_sys_user index 28983632..8a3835c2 100755 --- a/bin/v_backup_sys_user +++ b/bin/v_backup_sys_user @@ -47,9 +47,6 @@ tmpdir=$(mktemp -p $V_TMP -d) # Prinitng status if [ -z "$output" ]; then echo "$(date +%m-%d-%y" "%H:%m:%S) System backup for user $user" - echo - echo "VESTA VERSION $VERSION" - echo "BACKUP VERSION 1.0" echo "TMPDIR is $tmpdir" echo fi @@ -300,7 +297,10 @@ then if [ -z "$output" ]; then echo -e "\t$(date +%H:%m:%S) system cron" fi - cp /var/spool/cron/$user $tmpdir/cron/ + + if [ -e "/var/spool/cron/$user" ]; then + cp /var/spool/cron/$user $tmpdir/cron/ + fi if [ -z "$output" ]; then echo @@ -375,23 +375,134 @@ if [ -z "$output" ]; then echo fi -# Move tmp backup to local storage -if [ "$BACKUP_SYSTEM" = 'local' ]; then +# Defining local storage function +local_backup(){ if [ -z "$output" ]; then - echo "ARCHIVE $V_BACKUP/$user.$V_DATE.tar" + echo "-- STORAGE --" + echo -e "\t$(date +%H:%m:%S) ARCHIVE $V_BACKUP/$user.$V_DATE.tar" fi # Checking retention - check_ret=$() + archives=$(ls -lrt $V_BACKUP/ |awk '{print $9}' |grep "^$user.") + archives_q=$(echo "$archives" |wc -l) + if [ "$archives_q" -ge "$backups" ]; then + archives_r=$((archives_q - backups)) + for archive in $(echo "$archives" | head -n $archives_r); do + # Removing old archives + if [ -z "$output" ]; then + echo -e "\tRemoving old $archive" + fi + rm -f $V_BACKUP/$archive + done + fi + # Creating final tarball cd $tmpdir tar -cf $V_BACKUP/$user.$V_DATE.tar . -fi + localbackup='yes' + if [ -z "$output" ]; then + echo + fi +} + + +# Defining ftp command function +ftpc() { + ftp -n $HOST $PORT <