#! /usr/bin/env python2
import os
import sys
import time
database = sys.argv[1]
location = sys.argv[2]
location = location.replace("DAY", time.strftime("%d"))
location = location.replace("MONTH", time.strftime("%m"))
location = location.replace("YEAR", time.strftime("%y"))
location = location.replace("HOUR", time.strftime("%H"))
location = location.replace("MIN", time.strftime("%M"))
location = location.replace("SEC", time.strftime("%S"))
command = "mysqldump "+database+" > "+location+".sql"
print command
os.system(command)
command = "tar -czvf "+location+" "+location+".sql"
print command
os.system(command)
command = "rm -f "+location+".sql"
print command
os.system(command)