Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

backup and dl sql over ssh

$
0
0
hi all.

i'm very new to AutoIt so please bare with me :)

here what i'd like to do:

- connect to db server using ssh
- dump the database to a .sql file
- ftp to the server and dl the .sql file

do some work on it locally

- ftp to the server and upload the edited .sql file
- connect to db server using ssh
- import the .sql to the database
- exit

here is how i did it:

$user = ...
$pass = ...
$db = ...
$connect = "e:\plink -ssh -pw " & $pass & " user@server.net"
$dl = "mysqldump -p -u " & $user & " " & $db & "> " & @MDAY & @MON & ".sql {ENTER}"

; db backup
Run(@ComSpec & " /C " & $connect)
Sleep(5000)
Send ($dl)
Sleep (3000)
Send($pass & "{ENTER}")
Sleep (5000)
Send ("exit{ENTER}")

;ftp dl
Run(@ComSpec & " /c " & "ftp server.net", "C:\Users\Administrator\Desktop\Moj")
Sleep (3000)
Send($user & "{ENTER}")
Sleep (3000)
Send($pass & "{ENTER}")
Sleep (3000)
Send("get " & @MDAY & @MON & ".sql{ENTER}")
Sleep(20000)
Send("bye{ENTER}")


that's only the receiving part. sending part is very similar.

now, although this works  i'm sure this can look much nicer. also it would be better if i could read output and use instead of sleep() for better speed and error handling that is non existent right now.

thoughts please.

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>