Error executing script: what's wrong?
Could someone give me a tips?
This is my script:
-----script-----
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect
# [(scp|sftp)://][user[:password]@]host[:port][/path/[file]] [/privatekey=key_file]
# open sftp://tmpupusr:T3mpupusr@10.39.132.150
open sftp://root:mypass@10.39.132.140
# Change remote directory
cd /usr/Backup/Mysql
# Remove old backup file
rm max_db_dump.sql.gz
# Change local directory
lcd Z:\
lcd Backup\MICSAD2
# Force binary mode transfer
option transfer binary
# Execute backup remotely
# call /usr/bin/mysqldump -uroot -hlocalhost -pmypass max > max_db_dump.sql
call /usr/bin/mysqldump -uroot -hlocalhost -pmypass max | gzip -c > max_db_dump.sql.gz
# Download file to the local directory Z:\
get max_db_dump.sql.gz
# Disconnect
close
# Exit WinSCP
exit
------end of script-----
The problem is that on remote server (10.39.132.140) mysql dump and .gz file is created correctly but an error is displayed when getting file.
It seems that winscp for some strange reason isn't able to get the file.
This is the error:
Host has not answered for more than 15 seconds. Still waiting...
Warning: Aborting this operation will close connection!
<A<bort: Abort
Terminated by user.
Session 'root@10.39.132.140' closed.
No session.
No session.
Unknown command '#close'.
Unknown command '#exit'.
winscp>
One useful thing to know in order to understand the problem is that when this error is displayed, executing "ls -lh" on remote server shows that dump file still continues to grows; thus I suspect that "get" begin before gz file is completely created. I tried to don't create a .gz file using standard mysqldump sintax (call /usr/bin/mysqldump -uroot -hlocalhost -pmypass max > max_db_dump.sql) but the problem is always the same
Obviously I have thought that I must find a way to put some sleep (although I don't know how to do it...) but I have others script that remotely create a gz file and they work perfectly.
For example I have scripts like this:
# Execute backup remotely
call sudo tar -zcvf micsad1_openads_bck_.`date +%Y%m%d`.tar.gz max/
# Download file to the local directory Z:\
get *.tar.gz
and this script work perfectly! Tar.gz file is created and THEN (after gz is finished) the get begin.
I searched on the forum problems related to "Host has not answered..." but I thing posts are related to others things...
Do you have any suggestion?
:(
Thanks