If you are following the Automatic Backup article, you may have a need to append the date at the end of the file which cannot be done using the arguments in the task scheduler.
Appending a date at the end of a backup file using Task Scheduler
If you are following the Automatic Backup article, you may have a need to append the date at the end of the file which cannot be done using the arguments in task scheduler.
To do so, you would need to create a .bat file that would get the date from the machine (most likely the server), launch database maintenance and run the backup. Then task scheduler would run off the .bat file instead.
First, open up Notepad by going to Start -> All programs -> Accessories -> Notepad. Then, copy and paste the following command lines:
ECHO ON
@REM Date forumla used: http://stackoverflow.com/questions/19131029/how-to-get-date-in-bat-file
@Rem parses out the date string (%date% in command prompt) by using tokens
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
set dow=%%i
set month=%%j
set day=%%k
set year=%%l
)
set datestr=%month%_%day%_%year%
THEN
start "" "C:\Program Files (x86)\ACCTivate\AcctivateDBMaint.exe" /B /C Demo /O /SILENT /F "ACCTivate_%datestr%.bkf"
Once the above text is in Notepad, Click “File” -> “Save as” -> then type in something like “Acctivate backup – Appends Date.bat” and click save. It will look like this when it’s saved:
Then start Task scheduler by going to Task Scheduler from Windows Start Menu > All Programs > Accessories > System Tools.
- Click on Create Basic Task
- Enter Acctivate Database Backup in the Name field and click Next
- Choose the backup frequency for the Task Trigger then click Next. The default Daily option is recommended.
- Leave the default Recur every 1 days setting and click Next
- Leave the default Action of Start a program and click Next
- Click Browse… to select the Program/script
- Then browse to the .bat file location.
After browsing to the .bat file location, you don’t need to change anything else except when you want to run the .bat file. See below.