Automate JMeter Script Backup

Automate JMeter Script Backup

JMeter has an automated process to take the backup of each Test Plan or Script that you create. This is a good feature for a performance tester to save his work from any unexpected loss. This backup is available into the “backups” folder of JMeter directory. By the way, you do not need to set up anything to take the default backup of the script. Backup files for a Test Plan/Script are automatically created by JMeter when you save a Test Plan. The illustration goes as:

Figure 01: Backups Folder and file location

Default Setting of JMeter Script Backup:

Initially, when you download a fresh copy of JMeter then this “backups” folder is not present in JMeter directory. Only when you start creating any Test Plan/Script then automatically the backup feature is enabled which creates a “backups” folder. After that JMeter starts saving the backup files for each Test Plan/Script in this folder.

Also, there is no expiration time set for these backup files which mean they are stored forever unless you delete them manually. You can delete these backup files when you find them unnecessary or want to free up the memory space.

By default, only 10 backups are preserved per Test Plan/Script in backups folder. For example, if you have a Test Plan with filename “JPetStore1.jmx”, then only 10 latest backups of this Test Plan will be kept in “backups” folder. The older backups for this Test Plan, except latest 10, will be automatically deleted. Similarly, if there is another Test Plan with filename “WebTours1.jmx”, so only 10 latest backups of this Test Plan will be kept in the “backups” folder.

Custom setting of JMeter Script Backup:

You can customise the setting of automated JMeter script backup process by changing in the “jmeter.properties” file. Follow the below steps:

Step 1: Go to ‘/bin’ folder of JMeter and open ‘jmeter.properties’ file in notepad or notepad++

Step 2: Search for “JMX Backup configuration”. You will find 5 properties lines as shown below:

#jmeter.gui.action.save.backup_on_save=true
#jmeter.gui.action.save.backup_directory=
#jmeter.gui.action.save.keep_backup_max_hours=0
#jmeter.gui.action.save.keep_backup_max_count=10
#save_automatically_before_run=true

JMX Backup jmeter properties file
Figure 02: jmeter.properties File

Explanation of properties lines:

The first line “jmeter.gui.action.save.backup_on_save” has a default value “true” which indicates that backups will always be taken. You can give the value “false” if you do not want the backups to be taken or saved.

The second line “jmeter.gui.action.save.backup_directory= ” has no default value which means the backups will save in the “backups” folder of JMeter directory. You can give your own directory path if you want to save the backups at any other location.

The third line “jmeter.gui.action.save.keep_backup_max_hours” has a default value “0” which implies to keep the backup file forever. If you want backups to be deleted automatically after a certain period then give your own value in hours.

The fourth line “jmeter.gui.action.save.keep_backup_max_count” has 10 as default value. It indicates that JMeter will store up to10 latest backups per Test Plan/Scripts in the “backups” folder. You can give your own value if you wish this number to be more or less.

The fifth line “save_automatically_before_run” has a default value as “true” which signifies whenever you run a Test, JMeter will always save a backup of that Test Plan/Script before running the test.

If you want to do some changes, just uncomment the respective properties line by removing the “#” sign and set the corresponding desired value.

Remember:
Always use “Backslash” (i.e. “/ ”) while giving File path or Directory path in JMeter, because JMeter generally recognises the “Forward slash” (i.e. “ \ ”) as Escape Character.

Always keep an original copy of “jmeter.properties” file or paste the original properties lines in “user.properities” file and do the changes.

Step 3: Save “jmeter.properties” file after doing the changes and restart the JMeter.

The biggest advantage of this Backup feature is to prevent you from unexpected loss of script and rework, so keep it enable and get the benefit.


You may be interested:



Leave a Reply

Your email address will not be published. Required fields are marked *