Create and manage backup files

Logging data

The user can write text to file in the NC program using #MSG SAVE […]. New data is appended to the file, causing the file size to gradually increase.

Defining size and number of log files

To check the size and access to large files, the user can limit the maximum number of lines in the file. When the maximum size is reached, the file is backed up automatically and the original file is deleted.

To track the chronology of file changes, several backups (log files) can be saved. The user can also define the maximum number of backups. When the maximum number of backup files is reached, the oldest back file is discarded.

The size and number of backup files is defined with the command #FILE NAME […]. This refers to the file which is written with #MSG SAVE.

Syntax:

#FILE NAME [ BACKUP_LINES_MAX=.. BACKUP_COUNT_MAX=.. ]

BACKUP_LINES_MAX=..

Number of lines in the file since controller start-up. If this is overshot, a backup is created. This applies to files last programmed with <Number>.

BACKUP_COUNT_MAX=..

Maximum number of backups saved in parallel. If the maximum number is reached when a new backup is created, the older backup is overwritten.

Diagram of backup function
Diagram of backup function
Creating backup files
Creating backup files

Activating and deactivating the backup function

The backup function is activated by specifying a maximum number of lines > 0 and a maximum number of files > 0.

Deactivation takes place if one of these parameters is programmed with 0 or none of these parameters is programmed or at program end M30.

Notice

notice

The current maximum number of lines corresponds to the number of write accesses per #MSG SAVE command. In other words, the actual number of lines is not determined. This produces a difference in particular if a message containing several lines is written.

The original name of the backup file is specified by #FILE NAME [MSG=<name>]. The name of the backup consists of the original name, the count number <no> and the file extension .bak.

Example:

Test.log (original file)

 

Test1.bak , Test2.bak , Test3.bak, etc.

Behaviour at controller restart

When the controller is started, back files may already exist. The first time a new backup is created, no search is made for the oldest backup. This means that after controller start, a new backup always starts with 1.

Notice

notice

A backup is only deleted if it is necessary when a new backup is created.

No backup is automatically deleted at controller start-up, when the backup behaviour is defined by the NC command, in the event of an error or at NC reset.

The name of the last backup file and the current lines are saved. This means that the current state is always updated when the backup function is re-activated. This data is only deleted at controller restart. All other values for previously programmed filenames are discarded.