!--a11y-->
Backing Up and Restoring TREX Indexes and
Queues
You can use Python scripts to back up and restore TREX indexes and queues. To do this, you use the following scripts:
· Backing up TREX indexes and queues: backup.py
· Restoring TREX indexes and queues: restore.py
You can find these scripts in the python_supportdirectory in the TREX installation directory. <TREX_DIR>:
· On UNIX: /usr/sap/<SID>/TRX<instance_number>
· On Windows: <disk_drive>:\usr\sap\<SID>\TRX<instance_nummer>\

In a distributed TREX system landscape, you can perform the backup and restore for TREX indexes and queues simultaneously for all hosts that TREX is installed on and that TREX indexes and queues have been created on.
· To be able to start the Python scripts for data backup and restore, you must ensure that the following prerequisites have been met:
¡ On UNIX: Make sure that the environment variables defined in TREXSettings.sh or TREXSettings.csh are set.
¡ On Windows: Choose Start ® Programs or All Programs ® SAP TREX ® Instance <instance_number> ® Tools ®TREX_<instance_number> Console. In the command prompt that appears, the environment variables have already been set accordingly.
· Make sure that a backup directory is available at <backup_path> for the backup of the TREX indexes and queues. SAP recommends that you use another hard disk or breakdown-proof host for the backup directory. If necessary, create a new directory for this purpose (for example, N:\Backup).
...
1. Log on with the user <sid>adm.
This is the operating system user that you log on with to administrate TREX.
2. Go to the python_support directory that the backup.py script is located in.
3. To back up certain TREX indexes and queues in a backup directory, enter the following:
python backup.py –-useQueueServer --indexId=<index_name1>
--indexId=<index_name2> <backup_path>

backup -–useQueueServer --indexId=dpa_english
--indexId=dpa_german N:\Backup
The selected indexes and the associated queues are then saved in the following directories:
N:\Backup\index\
dpa_english
dpa_german
N:\Backup\queue\
dpa_english
dpa_german
If you do not use the indexId parameter to specify certain indexes, the system saves all available indexes. The --useQueueServerparameter allows you to specify that the indexes are saved with their associated queues. Without this parameter, the system saves only the specified indexes (without the queues).

For more information about using the Python script backup.py, see the help function for the Python script at python backup.py --help.
During data backup for indexes and queues, you can continue to run TREX in all TREX landscapes (TREX single-host installation and distributed TREX system with centralized and decentralized data storage):
· All TREX servers and still available.
· Searching and indexing is possible for all indexes.

At the moment, consistent backup of join indexes is only possible if indexing for the indexes being backed up is not running at the same time.
You can restore an index (and the associated queue, if necessary), if the index has been rendered unusable. This process reverts to a previously saved version of the index with the same name to replace the defective original index. In order for the restore process to work, you must first delete the defective original index.
4. Log on with the user <sid>adm.
5. Go to the python_support directory that the restore.py script is located in.
6. To restore a specific index and the associated queue and delete the existing original index at the same time, enter the following:
python restore.py -–useQueueServer --delete <backup_path> <index_name>

python restore.py -–useQueueServer --delete N:\Backup dpa_english
The selected index and the associated queue are then restored in the corresponding directories for the TREX installation, <TREX_DIR>\index.
The --delete parameter allows you to specify that the system is to delete the specified index. The --useQueueServer parameter allows you to specify that indexes are restored with their associated queues. Without this parameter, the system restores only the specified indexes (without the queues).
If you want to restore more than one index, you use the indexId parameter to specify the individual indexes:
pyton restore.py –-useQueueServer --delete
--indexId=<index_name_1>
--indexId=<index_name_2> <backup_path>

restore --useQueueServer --delete --indexId=dpa_english
--indexId=dpa_german N:\Backup

For more information about using the Python script restore.py, see the help function python restore.py --help.
During data restore for indexes and queues, you can continue to run TREX in all TREX landscapes (TREX single-host installation and distributed TREX system with centralized and decentralized data storage) under the following conditions:
· All TREX servers and still available.
· Searching and indexing is possible, except with the indexes that are being restored.