#!/bin/ksh backupdir=/data/backup/ # FTP creds server=ADDRESS_HERE user=USER_HERE pass=PASS_HERE fmain() { print checking for previous backup processes... \\c tmp=`pgrep lftp` [[ -n $tmp ]] && print ANOTHER LFTP PROCESS IS STILL RUNNING && print "$tmp" && exit 1 print done print calculating needed space... \\c needed=`du -s $backupdir | awk '{print $1}'` print $needed #100GB storage in kbytes #echo $((1024*1024*100)) avail=104857600 print available space is $avail (($avail <= $needed)) && print NO SPACE LEFT ON REMOTE SITE && exit 1 print uploading $backupdir\*\* to $user@$server... lftp -f " open $server user $user $pass lcd $backupdir mirror -R -c --delete-first --parallel=2 bye " && echo done } date fmain $@ date #date=`date +%Y-%m-%d-` #lftp: rm -rf / #lftp: mput -c ${date}*