Dear David,
We use the following code snippet that will be used as inbound TPS to backup/archive in FTP and SFTP. You may need to pass backup/archive directory of SFTP server. Kindly review the code snippt, and let me know if any clarifications needed.
# Extract the message ID from the incoming message arguments
keylget args MSGID mh
# Retrieve the raw message data using the message handle
set data [msgget $mh]
# Extract DRIVERCTL metadata from the message
set Filekeys [msgmetaget $mh DRIVERCTL]
# Get the file path from the DRIVERCTL metadata
keylget Filekeys FILENAME FilePath
# Get the backup directory path from the incoming arguments
keylget args ARGS.BKUPDIR bkupDir
# Extract the filename from the full file path (get the last element after ‘/’)
set Filename [lindex [split $FilePath /] end]
# Create a copy of the original message to modify and send back
set new_mh [msgcopy $mh]
# Prepare the output directory and file name for the outgoing message
keylset fileKeys OBDIR $bkupDir
keylset fileKeys OBFILE $Filename
# Wrap the fileKeys in a FILESET structure as required by Cloverleaf metadata format
keylset filesetKeys FILESET $fileKeys
# Set the updated DRIVERCTL metadata on the copied message
msgmetaset $new_mh DRIVERCTL $filesetKeys
# Continue processing the incoming message and send the modified message back
# as an acknowledgment that the file was fetched successfully
return “{CONTINUE $mh} {OVER $new_mh}”