Storing Startup Parameters in a Text File



Sometimes the command line used to start nnBackup becomes very long. Such a line is too cumbersome to be used in batch files, schedulers or in console window. To avoid this problem, nnBackup can "read" startup parameters from a text file. Command line option -f serves just this purpose.

For example, instead of typing the following command line:

nnbackup.exe sync -log log\nnbackup.log -i d:\first\source\ -i d:\second\source\ -o e:\backup\sources\ -m *.cfg,*.ini -x *.bsy,*.lck -s -v -q -da -ad

you can save all parameters (sync -log log\nnbackup.log -i d:\first\source\ -i d:\second\source\ -o e:\backup\sources\ -m *.cfg,*.ini -x *.bsy,*.lck -s -v -q -da -ad) in text file, e.g. in test.cfg, and then start nnBackup with this command:

nnbackup.exe -f test.cfg

When you store nnBackup startup parameters in a text file, you don't have to type them all in one line (like you have to do in a console): linefeeds and white space between options are ignored. In any place of this file you can use the special character of "comment until the end of line", used in Forth programming language: \ (backslash+space).

Here is an example of how a file with parameters might look like (including comments and arbitrary linefeeds):

\ synchronising two directories
   
sync
   
\ input directory:
-i H:\ARTICLES\
\ output directory:
-o "E:\MY DOCUMENTS\ARTICLES\"
\ log file 
-log D:\TOOLS\NNBACKUP\LOG\nnbackup.log
   
\ additional options:
   
-v \ verbose
-s \ process subdirectories
-e \ copy empty directories
-da \ remove from the output directory those files  , 
\ that are not present in the input directory 
-ad \copy files

In the file where you store the startup options, you can use not just commands and options, but also nnBackup predefined variables.


Most of the command line options take certain parameters as their arguments: for example, option -i takes as its argument the name of an input directory, option -m is given a list of filename masks as its argument, option -D takes the date of creation/modification of a file etc. Parameters for option can also be stored in text files. For this purpose, you can use special syntax: @filename. It can be used with all command line options which take parameter as their arguments (-m, -x, -i, -D, -dn etc.).

For example, instead of constantly repeating the same masks in command line, you can save them in file mask.cfg:

*.txt
*.doc
*.rtf
*.htm*
*.pdf

and start nnBackup this way:

nnbackup.exe copy -i c:\data -o d:\backup\data -m @mask.cfg -v -s

As you can see from the above example, each parameter should be placed on a separate line; otherwise, the @filename syntax may not function correctly.

Here is another example: let us use the @filename syntax to specify several output directories. For this purpose, we shall create a file named src.txt:

c:\data
c:\another_data
c:\important_data

Now we can start nnBackup in the following way:

nnbackup.exe copy -i @src.txt -o d:\backup\data -v -s

Another area where the @filename syntax is used is processing of filelists.

@filename syntax comes very handy when you frequently use the same parameters or if parameters are dynamically generated by an external program: all you have do to use them is to save them in a text file.