Jump to content

Recommended Posts

Posted

I'm automating a mysqldump sequence from the CMD and I can't figure out how to have A3 make the CMD put a datestamp in the filename. I would like databasename%DATESTAMP%.sql but I get that *exact* output rather than it being replaced with the datestamp.

I'm not sure whether I need the AutoIT script function for date or CMD function for it but in either case the output contains the verbose command rather then the preproccessed output in the filename.

Any help would be appreciated.

Thanks,

Joshua

Posted

Thanks MHz,

I tried the following and got an error that $var was not a recognized command or batch process from CMD. Can you recommend? I have pasted the script below minus the privilege escalation info to run as root.

; blocks keyboard/mouse input
BlockInput(1)

; Opens CMD window
Run("cmd.exe")
Sleep(555)
$var = @MON & @MDAY & @YEAR
; Changes to local working dir and starts mysqldump
Send("cd c:\dump{ENTER}")
Send("mysqldump -u root cascade > cascade & $var & .sql{ENTER}")
Sleep(5000)
Send("exit{ENTER}")

BlockInput(0)
oÝ÷ Ú«¨µéÚ

:whistle:

Posted

This Works Awesome!

This is perfect. Now I'll just fire this off on a nightly schedule and I should be golden.

Send("mysqldump -u root cascade > cascade" & $var & ".sql{ENTER}")

Send("mysqldump -u root cascade > cascade" & $var & ".sql{ENTER}")

Posted (edited)

...Now I'll just fire this off on a nightly schedule...

Will the system be locked? Probably will not run as written on a locked system.

Edit: Look at the sample code in the help AutoIt3 file under StdinWrite. That runs on a locked system.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted

I currently have the system set not to lock down becasue it is a dedicated server and some processes are login/user dependant. I will check out the StdinWrite info sometime soon though. That would be very appropriate for several of my other servers.

Now that this works I'm going to expand the script and have it sftp or ssh the dump to a remote location.

My next task will be to create another script to run on the first day of the month and clear out all but the last weeks backups. This should be a bit more challenging but neccesary to prevent bogging the system down with various iterations of a data file. I'm thinking that I can use the same variable option you've given me in a different way to accomplish this task.

Thanks again,

Joshua

Will the system be locked? Probably will not run as written on a locked system.

Edit: Look at the sample code in the help AutoIt3 file under StdinWrite. That runs on a locked system.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...