Embed date in SQLBase unload filename

14925 pts.
Tags:
Backup software
Scheduled Tasks
Scripts
SQL
I have a scheduled task to runs a backup script each night using a program called SQL_Talk for Windows version 9.0.1. I am using this program to unload a SQLBase database each night for backup purposes. I have a separate script for each night of the week. Below is the Monday script:
	
set server server1;
connect testdb 1 sysadm/XXXXXX;
update statistics on database;
check database;
commit;
SET BULK ON;
unload database z:backupsVIS_Monday.UNL;
disconnect all;
EXIT;
Instead of unloading to a file named VIS_Monday.UNL is it possible to change the script to embed the date of the unload in the filename? For example VIS_Feb232009 ? This would make for fewer scripts and I would not have to manually embed the dates in the file names. If not, is there another scripting program that will allow this to be done? Thanks! -Flame

Answer Wiki

Thanks. We'll let you know when a new response is added.

It’s been a long time since I worked with a Centura database; but I still have some documentation books, so I tried to find something that could help in this matter, but I was not able to find anything. It seems that Sql Talk (BAT option, which I assume you are using) doesn’t allow something like that.

But, how about a separate small application or script to dynamically build the script file according to the current date ?

This BAT script could do something similar (you will probably need to edit it according the output format of your date).

<pre>set date=%date:~0,2%_%date:~3,2%_%date:~6,4%
echo set server server1; > script.txt
echo connect testdb 1 sysadm/XXXXXX; >> script.txt
echo update statistics on database; >> script.txt
echo check database; >> script.txt
echo commit; >> script.txt
echo SET BULK ON; >> script.txt
echo unload database z:\backups\VIS_%date%.UNL; >> script.txt
echo disconnect all; >> script.txt
echo EXIT; >> script.txt</pre>

You could then schedule the execution of this script, and then the execution of the backup through Sql Talk.

Hope this helps.

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Flame
    Carlosdl, I made a few changes listed below, but this is EXACTLY what I needed. The changes is made removed the space that was appearing after the filename, but before the ".txt" extension as well as a space that appeared between the filename and the “;” Thank you! -Flame Modified bat file:
    del script.txt
    set date=%date:~0,3%_%date:~4,13%.UNL; 
    echo set server server1; >> script.txt 
    echo connect testdb 1 sysadm/XXXXXX; >> script.txt 
    echo update statistics on database; >> script.txt 
    echo check database; >> script.txt 
    echo commit; >> script.txt 
    echo SET BULK ON; >> script.txt 
    echo unload database z:backupsVIS_%date% >> script.txt 
    echo disconnect all; >> script.txt 
    echo EXIT; >> script.txt
    
    Resulting Script:
    set server server1;  
    connect testdb 1 sysadm/XXXXXX;  
    update statistics on database;  
    check database;  
    commit;  
    SET BULK ON;  
    unload database z:backupsVIS_Mon_03/02/2009.UNL;   
    disconnect all;  
    EXIT; 
    
    Perfect!
    14,925 pointsBadges:
    report
  • Flame
    Wow, Silly mistake (which the system infomed me of...) You can't have a "/" in a file name (doh!) Fixed code below: Batch file: del Autoname_Unload.sql set date=%date:~0,3%_%date:~4,2%_%date:~7,2%_%date:~10,4%.UNL; echo set server server1; >> Autoname_Unload.sql echo connect testdb 1 sysadm/XXXXXX; >> Autoname_Unload.sql echo update statistics on database; >> Autoname_Unload.sql echo check database; >> Autoname_Unload.sql echo commit; >> Autoname_Unload.sql echo SET BULK ON; >> Autoname_Unload.sql echo unload database z:backupsVIS_%date% >> Autoname_Unload.sql echo disconnect all; >> Autoname_Unload.sql echo EXIT; >> Autoname_Unload.sql Resulting Script: set server server1; connect testdb 1 sysadm/XXXXXX; update statistics on database; check database; commit; SET BULK ON; unload database z:backupsVIS_Mon_03_02_2009.UNL; disconnect all; EXIT; That's better! Thanks again Carlosdl!
    14,925 pointsBadges:
    report
  • Flame
    Interesting note here... The files I copied had the "" symbol in the correct places in the paths of the batch files... but they did not seem to paste into the discussion section... Is there a way to edit the comments to reflect this?
    14,925 pointsBadges:
    report
  • Flame
    Apparently you can't even type the symbol that is a mirror image to "/" in the discuss section. Interesting...
    14,925 pointsBadges:
    report
  • carlosdl
    Yes Flame, you cannot use the mirror of '/' here (I guess it is taken as some type of escape character)... :-( I noticed you change '>' for '>>' in this line: echo set server server1; >> script.txt Have you tried running this script more than once ? I think it will cause the new script to be appended at the end of the previously generated, so the file will grow endlessly.
    69,510 pointsBadges:
    report
  • Flame
    Thats why the first line of the script is : del Autoname_Unload.sql I though the single ">" was a typo... (Needed more coffe this morning I guess...) I'm planning on running a test tonight, then going live after that. Thank you again! Flame
    14,925 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following