Reputation: 2028
If someone could not understand what exactly i'm trying to do, here it goes.... I use amazon cloud server, so i want to backup my database with a python script, hopefully i've got it working from command line.....
When i do a backup, it should run mysqldump on amazon server and save it into amazon server itself!! /home/abhilash/dumps/
So how do i use this command in python?? I'm new to python and trying this for a while...
mysqldump -h 50.12.xx.xx nameofdb -u root -p |gzip -9 | ssh [email protected] "gzip -d>/home/abhilash/a.dump"
I want to use the above command in python, whats the easiest way?? thanks!!
Upvotes: 1
Views: 1392
Reputation: 18972
Maybe you should take a look at fabric
It may be overkill for a single command, but as soon as your deployment/backup tasks become complex, it will surely pay off.
Fabric is a Python (2.5 or higher) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.
There are a lot of good example fabfiles to learn from on github.
To use fabric in conjunction with mysqldump see these blog posts:
Upvotes: 4