0

I am fairly new to putty, need your help guys I would repeatedly connect to a linux server using putty almost everyday then connect to one more linux sever from within previous linux server as it contains database, then login to mysql and take a database back up

I want to automate this process by creating a bat file as am on windows 7, i was able to login to putty and then to mysql, but console disappears after that

  1. login to putty with username password
  2. ssh to another server and login with username password
  3. login to mysql then take a db back up using mysql dump
  4. copy the db backup file to desktop

Thanks in advance

Batiaev
  • 1,115
  • 1
  • 14
  • 29
Tushal
  • 11

1 Answers1

1

When your goal is making the backup, you do not need to automate Putty. You can make a unix script that will call mysql and make a backup. When that script works, you can add it to crontab (Unix scheduler), so it will run every day.
You need some more testing before crontab works well: your environment in an interactiv session will be different.

Edit: Did not answer the last part: And 4. copy the db backup file to desktop

There are different ways for transporting the backup. You can have a mounted drive, shared directory, or use some transport protocol like rsync or scp. I can not tell which fits best in your situation.

Walter A
  • 16,400
  • 2
  • 19
  • 36
  • How would a Unix script download the backup file and put it on the Windows desktop? – Emil Vikström May 09 '16 at 12:17
  • Isn't `putty` an interactive command? And why do you have to hop from one server to another? – Michael Vehrs May 09 '16 at 13:54
  • the db and the application has their own servers due to this any interaction with the db i need to first login to application server and from that access the db server – Tushal May 10 '16 at 12:11
  • Thanks Walter for your reply, but am using a windows pc at work place so writing unix scripts is out of the question, if you have any other alternatives please do suggest thanks – Tushal May 10 '16 at 12:17
  • Share a folder on your Windows PC (better: some shared windows server), and make a backup from windows. I never did this myself, but perhaps http://stackoverflow.com/a/10847184/3220113 helps. Use Windows task manager for a daily task. – Walter A May 10 '16 at 15:39