TapeTrack Documentation

Because there is more to tape management than you ever realized

User Tools

Site Tools


technote:netcat:linux_sync

Executing Sync Using Netcat

Prerequisites

  • root or sudo privileges to install software and scripts.
  • Knowledge of using vi or similar to create and enable scripts
  • Netcat installed on your system, to check run the command ncat –version
  • tcp access to the server TapeTrack database and Sync is installed on
  • xinetd installed on the server TapeTrack database and Sync is installed on
  • Knowledge on how to extract the Volume data from your backup server (eg TSM, NetBackup)

Setting Up Sending Server

Create a script (eg run-remote-sync.sh) on your sending server, with executable permissions.

Add the required code to extract the Volume data to be Sync'd with your TapeTrack (receiving) Server into a text or CSV file.

vmquery -W -a > report.txt

Add the call Netcat, including the IP address and Port of the receiving server, along with the input data file. In the example the IP is XXX.XXX.XXX.XXX and Port 4545, these need to be replaced with your actual IP and Port numbers.

You can also record the output from the Sync if required by redirecting the stdin stream to file (eg Sync-output.txt).

nc XXX.XXX.XXX.XXX 4545 < ./report.txt > Sync-output.txt

By placing both the vmquery code with the netcat execution code in the same script, you can schedule the script to run using cron or similar to execute the data extraction and call to the Sync process on the receiving server.

Setting Up Receiving Server

Create an entry in the /etc/services file with the name of the service and port number and protocol. In this example we will use the service name receive-sync and the port 4545 to match the sending server details. These details can be modified to suit what name and port you require, as long as the sending and receiving ports match.

receive-sync   4545/tcp  

Create the xinetd service file (receive-sync) in /etc/xinetd.d with the minimum code, with the optional inclusion of the only_from = YYY.YYY.YYY.YYY. Only use the only_from if your IP address (or range) remain static.

 service receive-sync
 {
      disable         = no
      socket_type     = stream
      protocol        = tcp
      port            = 4545
      wait            = no
      user            = root
      server          = /etc/tapetrack/scripts/runSync.sh
      server_args     = -S user:-password@localhost
      only_from       = YYY.YYY.YYY.YYY
      log_on_failure  +=USERID
 }

For other options see the Linux xinetd manual pages.

Restart the xinetd service to refresh the data.

 systemctl restart xinetd
 

Create Script To Execute When Port 4545 Request Is Received

Create a script at /etc/tapetrack/scripts/runSync.sh (or a location of your choice as long as the location matches the server address in the xinetd service file) and give it executable permissions.

Add the code to execute the Sync, including the full path to the ttidef file

#!/bin/bash
cd /etc/tapetrack/scripts/

/bin/TMSS10Sync -S user:-password@localhost -d netcat-sync.ttidef

exit

When the Sync program is executed by the sending server with a call to the port, the data file will be passed to the Sync program via the stdin stream.

Ensure the ttidef file is either in the same directory, or at the location stated in the script so the Sync program has access.

Examples of ttidef files:

Output from the Sync process will be passed back to the sending server from the stderr stream to the stdin stream.

This can be altered to write the output to file on either computer by using the > and 2> redirection streams to text file if required.

technote/netcat/linux_sync.txt · Last modified: 2021/06/16 02:05 by scunliffe