Using Command Line Tools for Customized Backup and Recovery
Customized backup of the accelerator can be performed using command line tools provided with the Accelerator database and replication software.
Data recovery likewise utilizes command line tools provided with the accelerator database and replication software.
Hubble Accelerator Database Table Backup
-
Log on to the Accelerator server and check you have enough space to take backups of data.
Note: The backup process creates uncompressed copies of the tables, and hence will consume disk space. Best practice recommendation is to create an NFS mount to a remote server to store the backup of your Accelerator data.
-
Create a directory to hold the backups:
mkdir /mnt/ybdata/<Backup Directory Name> -
Navigate to the new directory:
cd /mnt/ybdata/<Backup Directory Name> Optionally, if required you can create sub directories for each schema you are backing up.
-
To copy all the tables in the schema owned by the database user:
copydb <database name> -u<DB UserName> -
To copy one or multiple tables from the schema owned by the database user:
copydb <database name> -u<DB UserName> -r<TableNamel> <TableName2>
The command that is used to take a backup of the table and data is called copydb, the function when run will create two files copy.in and copy.out. These files are then used to create the export data files (copy.out) and then to restore the tables and data (copy.in).
The copydb command takes the following parameters:
Running the copydb command will as previous explained create two files copy.in and copy.out. For example, if I wanted to backup TableA from the replication schema I would run:
copydb db -ureplication -rTableA
This will create copy.in and copy.out in the directory where I ran the command.
Then run the export command to generate the data file backup, based on the copy.out file. The syntax for the export command is:
sql <database name> -u<DB UserName> < copy.out
For example:
sql db -ureplication < copy.out
This will create individual data files named <tablename>.<schema> in the directory that you ran the command from. For example, TableA.replication.
Exporting Replication Tasks
-
Log on to the Accelerator server and change directory to /opt/attunity/replicate/data/imports:
cd /opt/attunity/replicate/data/imports -
Change the Accelerator user account, to use the Qlik user:
su qlik -
To export an individual task enter the following:
repctl exportrepository task=<name of task>For example, if the task is called PRODDTA, then you would enter (note the task name is case sensitive):
repctl exportrepository task=PRODDTA -
To export all tasks, enter the following:
repctl exportrepository A
jsonfile will be created in the /opt/qlik/replicate/data/imports directory. This can now be copied from the Accelerator (SCP) and to your backup location.
Compressing and Decompressing Backup Files
The Accelerator has both tar and pigz installed by default. Tar to create a tar file containing the file(s) and pigz to compress the tar file
Create a tar file
To run a tar command over the complete directory you have been using to create your backups, navigate down:
cd..
Then run the following:
tar -cvf <name for tar file>.tar <directory_to include in_tar_file>
For example if your tar file was to be called replication.tar and your directory is called replication then you would enter:
tar -cvf replication.tar replication/
Compress tar file
You can then compress the tar file using pigz:
pigz <name of file to compress> --best -k
the -k flag indicates that you want to keep the source file, in our case we do not want to keep the source file so this will be omitted for our example:
pigz replication.tar --best
will create the compressed file replication.tar.gz and remove the original replication.tar file. You can now copy the compressed file off the accelerator server, to your backup location, using SCP or equivalent.
Decompress file
To decompress a pigz compressed file:
pigz -d <name_of_compressed_file>
For example if the compressed file was called replication.tar.gz, then run the following:
pigz -d replication.tar.gz
This will create the decompressed file replication.tar
Extract tar file
To extract the contents from a tar file:
tar -xvf <name of tar file>
for example, if you tar file is called replication.tar then:
tar -xvf replication.tar
Restoring Data
Log on to Accelerator.
Copy the backup file onto the server (SCP) and into the directory that the backup was created from (see Hubble Accelerator Database Table Backup).
-
Decompress the file if required (see Compressing and Decompressing Backup Files).
Note: If the location of the files is different to the location the backup was made from you will need to edit the
copy.infile and change the location specified in the file to the new location of the backup files. Thecopy.infile contains sections for Creating Tables, Grant Select and Copying Data, if you want to restore the data, but the table already exists in the database, then you would need to edit thecopy.infile accordingly. -
Then to use the copy.in file to import the data run:
sql <database_name> -u<DB_UserName> < copy.inFor example:
sql db -uhubble < copy.i
Importing Replication Tasks
Note: If you are importing a backup file, the backup file will also contain the connection details (encrypted), after the import process has been completed, the password used for each of the database connections is removed. The password will need to be reĀ entered in the manage database connection dialog for each connection.
-
Copy the backup file (json) onto the accelerator server in the Linux directory:
/opt/qlik/replicate/data/imports -
Log onto the accelerator server and change the owner of the backup file to the user Qlik:
chown qlik:qlik <FileName.json> -
Log in or change the accelerator user account, that you are logged in as, to the user Qlik:
su qlik -
To import the backup file (json) enter the following:
repctl importrepository json_file=<Name of Json File>For example, for a json file named Ora_Rep_F0911.json the following command would be run:
repctl importrepository json_file=Ora_REP_F0911Note: The name of the file is case sensitive and you do not need to enter the
.jsonextension.