SFTP Server File Backup to Subfolder After Deletion by Cloverleaf Interface

Clovertech Forums Cloverleaf SFTP Server File Backup to Subfolder After Deletion by Cloverleaf Interface

  • Creator
    Topic
  • #122103
    David Ma
    Participant

      We have a SFTP interface in Cloverleaf that deletes files from the SFTP server after they are processed. We need to back up these files to a folder on the SFTP server so that other teams can access them.

      Does anyone have any ideas—or perhaps a TCL script—that could perform this task?

      Thanks!

      David

    Viewing 1 reply thread
    • Author
      Replies
      • #122104
        Jim Kosloskey
        Participant

          One way I can think of is to route the messages to the OB side of the thread (or another sftp thread) pointing the OB side to the directory where you want the archive/backup to exist. I think the metadata will contain the file name but you may need to provide the directory path.

          email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

        • #122105
          Ramachandran R
          Participant

            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}”

        Viewing 1 reply thread
        • You must be logged in to reply to this topic.