Backups from VAMI to SFTP server fail with "Err: curl: (79) Could not open directory for reading: Bad message from SFTP server"
search cancel

Backups from VAMI to SFTP server fail with "Err: curl: (79) Could not open directory for reading: Bad message from SFTP server"

book

Article ID: 377441

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • When trying to take backups of the vCenter in the VAMI to a 3rd party SFTP server we see the backup fail in the VAMI UI
  • /var/log/vmware/applmgmt/backup.log 

    YYYY-MM-DDTHH:MM:SS [20240709-122522-23788036] [MainProcess:PID-4270] [FtpStorageIOLib::_process_curl_output:FtpStorageIOLib.py:133] ERROR: sftp cmd failed. RC: 79, Err: curl: (79) Could not open directory for reading: Bad message from SFTP server

Environment

vCenter 7.x

Cause

As part of the backup process, when the vCenter executes a curl command to list the available backup directory, a successful response is returned if the target directory exists.
In cases where the directory does not exist, the expected behavior is for curl to return error code 78 (remote file not found) or 19 (resolved FTP error).

However, in some environments that utilize a specific variant of an SFTP server, curl returns the error code 79 instead. This deviation from standard behavior appears to be environment-specific.

Resolution

This issue is resolved in 8.x versions of the vCenter

As a workaround, we can update the logic to treat the return error code (79) as a valid response indicating a non-existent directory. When this error is encountered, the system will proceed to create the directory as expected.

Workaround

We can edit the list of expected responses on the vCenter to add curl(79)  to resolve this issue

  1. Backup script file: /usr/lib/applmgmt/backup_restore/py/vmware/appliance/backup_restore/plugins/FtpStorageIOLib.py

    cp /usr/lib/applmgmt/backup_restore/py/vmware/appliance/backup_restore/plugins/FtpStorageIOLib.py /usr/lib/applmgmt/backup_restore/py/vmware/appliance/backup_restore/plugins/FtpStorageIOLib.py.orig

  2. Edit /usr/lib/applmgmt/backup_restore/py/vmware/appliance/backup_restore/plugins/FtpStorageIOLib.py as below:

    Within the method "def dir_exists", look for the following lines:

    if (cmd_res.returncode in [
    CurlEC.DOWNLOAD_FAILED, CurlEC.REMOTE_FILE_NOT_FOUND,
    CurlEC.REMOTE_ACCESS_DENIED]):
    return False

    and update it to

    if (cmd_res.returncode in [

    CurlEC.DOWNLOAD_FAILED, CurlEC.REMOTE_FILE_NOT_FOUND,
    CurlEC.REMOTE_ACCESS_DENIED, 79]):
    return False

3. Retry the backup