Hi.
A simple way to automate backups and is very reliable, is using AutoHotkey (open source free application). It is far better than Hotcopy backup which does not understand the state of the database. I use Nav 2009, classic fbk database.
I’ve attached the script file (autohotkey) and the batchfile that I created.
The bat file is called zip.bat to agree with the file in the script, obviously you can call it what you like so long as you change the script as well
You can convert this script to an executable with Autohotkey so it runs nicely with task manager. on any Server or PC, I have run it with Win 7 and XP
What it does:
The script/Executable starts your Nav application, uses the tabs and keystrokes that you would normally enter yourself and then kicks off the backup, once saved it then call a batchfile to rename compress, and copy the file to another location (I do this because the nav backup for me is around 2.5gb - compressed it is down to about 130mb. I test quite frequently and have not had an issue in 2 years.
Because I backup over 2gb I end up with 2 files to compress and copy but if you had 3 or four or more you just need to duplicate the lines in the batchfile with a rename of the file in each duplicate section.
Be aware: If you are using your desktop and another program is in the foreground when the taskmanager starts then, the script will attempt to operate on it instead of opening Nav . (I just kick it of manually from the executable in my 7Z-NAV folder)
You will be warned for 30 seconds that the backup is about to start
You can copy and paste the script below to configure it for your environment, it looks a bit daunting if you don’t do this kind of stuff but I assure you it is all very easy. I’m sure there is a scripter out there who can improve on my effort.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir c:\7z-NAV ; Ensures a consistent starting directory.
MsgBox , NAV Backup, Backup Process will start in 30 seconds, 30
FileDelete, d:\NAV\NAV-Daily.* ;Deletes file(s) created for last backup
run, "C:\Program Files (x86)\Microsoft Dynamics NAV\60\Classic\fin.exe"
WinWaitActive, Techsil-Microsoft Dynamics NAV Classic, , 2 ;Wait for main Window to open
sleep 1000
send !F b O
sleep 400
send {Enter}
sleep 400
Send !F m O
sleep 400
send {Enter}
sleep 400
send !W A
sleep 1000
send !t b ;Keystrokes = ALT Tools > Backup
SetMouseDelay, 2000
WinWaitActive, Backup, , 2 ;Wait for Backup Window to open
Send {Tab 2}
Send {Enter} ;Backup should start at this point
Send {Enter}
Send {Enter}
WinWait, Microsoft Dynamics NAV Classic
WinWaitClose ;Wait for the backup window to close
sleep 1000
send !W A
sleep 1000
send !f x ;Keystrokes=Alt File > Exit
sleep 1000
runwait zip.bat
The batch file that is called is below, it copies and compresses and attaches a date. you will see that it is duplicated because I have two two files created by NAV so they are named slightly differently.
Rem Tasks below are scheduled through “TASK SCHEDULER” and runs
Rem once every week day after the NAV backup at 16:25
7za a -t7z “x:\NAV Backups\NAVarchive.7z” “d:\NAV\NAV-Daily.fbk” -r -mx7 -mmt x=7 s=500f200m -wx:\tempzip
Set FileDate=%date:/=%
ren “x:\NAV Backups\NAVarchive.7z” NAVarchive%FileDate%.7z
7za a -t7z “x:\NAV Backups\NAVarchive2.7z” “d:\NAV\NAV-Daily2.fbk” -r -mx7 -mmt x=7 s=500f200m -wx:\tempzip
Set FileDate=%date:/=%
ren “x:\NAV Backups\NAVarchive2.7z” NAVarchive2–%FileDate%.7z