Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ###GLOBALS###
- dbhost='localhost'
- table='asteriskcdrdb.cdr'
- dbuser='root'
- dbpass='place_your_password_from_mysql_here'
- dst='place_extension_of_your_queue_or_exten'
- tmpdir='/tmp/temprec'
- rm $tmpdir/*
- mkdir $tmpdir
- mounth=$(date +%m)
- year=$(date +%Y)
- for (( day=1; day<32; day++ ))
- do
- nextday=$(($day + 1))
- if [ "$day" -lt "10" ]
- then
- aday=0$day
- else
- aday=$day
- fi
- cd /var/spool/asterisk/monitor/$year/$mounth/$aday/
- cp $(
- start="$year-$mounth-$aday"
- stop="$year-$mounth-$nextday"
- #/usr/bin/mysql -u$dbuser -p$dbpass -h$dbhost -Bse
- sql="SELECT recordingfile FROM $table WHERE calldate BETWEEN '$start' AND '$stop' AND dst LIKE '$dst' AND disposition LIKE 'ANSWERED' ORDER BY RAND() LIMIT 2; "
- /usr/bin/mysql -u$dbuser -p$dbpass -h$dbhost -Bse "$sql"
- ) $tmpdir
- done
- zip --password PASSWORD_FOR_THIS_ZIP_ARCHIVE -r -5 $tmpdir/$year-$mounth.zip $tmpdir/*
- scp $tmpdir/$year-$mounth.zip USER@HOST:/var/www/html/your_shared_folder/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement