Database operations


Database backup

In this section, you can learn how to back up the data stored in your database. Data stored on the XTRF Platform is crucial to the activity of a translation agency and should therefore be carefully protected. 

This guide assumes you have PostgreSQL 9.6 installed, which is the minimal version for XTRF 8. If you ha have a different PostgreSQL version, please adapt the directories below accordingly.

Backup Procedure Policy

  • Setting up a backup procedure is obligatory and is the responsibility of the company which purchased the XTRF Platform. XTRF Management Systems Ltd. is not liable for any data losses resulting from the lack of a backup procedure or an improper backup procedure on the part of the company using the XTRF system. Please mind that this rule does not apply to an XTRF installation being a part of the System as a Service model.

  • It is strongly recommended to back up your data every day. Backing up your system data gives you the ability to secure against losing crucial information in case of the data is corrupted or destroyed.  

 

 To back up your data stored on the XTRF Platform, enter the following command in the Windows terminal, cmd.exe, where you need to replace the date sample, 2015-01-01, with the current one:

cd "c:\Program Files\PostgreSQL\9.6\bin" pg_dump -h localhost -O -x -U xtrf xtrf > "%UserProfile%\xtrf-archive-2015-01-01.sql"

 

The system asks you for the xtrf user password. Enter your password. 

Your database archive is now in the xtrf-archive.sql file in your profile directory (other locations may have permission restrictions). The name, of course, can be changed. The file should be kept on a separate hard drive for safety reasons (hard drives can fail).

Below find a batch script that can be saved, for example, as the XTRF-DB-Backup.bat file (it will work if your system date format is DD.MM.YYYY).

 

Setting Your Password
In the code sample below, please note that you need to provide your password replacing the YOUR_PASSWORD phrase.

 

XTRF-DB-Backup.bat

SET PGPASSWORD=YOUR_PASSWORD SET POSTGRES_FOLDER="C:\Program Files\PostgreSQL\9.6\bin" SET BACKUP_FOLDER="D:\xtrf_backups"   for /f "tokens=1-2 delims=: " %%a in ("%time%") do (     SET backuphour=%%a     ) SET backuptime=%backuphour%   for /f "tokens=1-3 delims=. " %%i in ("%date%") do (     SET backupday=%%i     SET backupmonth=%%j     SET backupyear=%%k     )   SET backupdate=%backupyear%-%backupmonth%-%backupday% SET BACKUP_FILE=xtrf_db_backup_%backupdate%_%backuptime%.sql   %POSTGRES_FOLDER%\pg_dump -U xtrf xtrf > %BACKUP_FOLDER%\%BACKUP_FILE%

Database restoration

If you have moved the database to another server or experienced data loss, you can restore the database which you archived earlier.  

 

If you want to restore your archived database, use the following command on a new, empty database:

 psql -f xtrf-archive.sql -U xtrf xtrf

 

If your database backup file is in another localization, you have to put a complete path with the file name, e.g., d:\Backup\xtrf-archive.sql