I'm trying to write a python script which backs up the database every midnight. The code i am using is below:
from subprocess import call
call (["mysqldump", "-u", "root", "-p*****", "normalisation", ">", "date_here.sql"])
The first problem i came across is that mysql thinks the ">" is a table when it is not, the query works fine when i run it from the command line (see below)
$ mysqldump -u root -p*** normalisation > date_here.sql
$ ls
backup.py date_here.sql
$
Sencondly, how do i get the script to automatically run everymidnight?
Thirdly, i need the .sql file to be saved as the date of the back up.