Skip to content

SFTP

Transfer files between local and remote servers via SFTP.

DAG-Level Configuration

yaml
ssh:
  user: deploy
  host: server.example.com
  key: ~/.ssh/deploy_key

steps:
  - id: upload_config
    action: sftp.upload
    with:
      source: /local/config.yaml
      destination: /remote/config.yaml

  - id: download_logs
    action: sftp.download
    with:
      source: /var/log/app.log
      destination: /local/app.log

Step-Level Configuration

yaml
steps:
  - id: upload_file
    action: sftp.upload
    with:
      user: deploy
      host: server.example.com
      key: ~/.ssh/deploy_key
      source: /local/file.txt
      destination: /remote/file.txt

Configuration

FieldRequiredDefaultDescription
userYes-SSH username
hostYes-SSH hostname
portNo22SSH port
keyNoAuto-detectPrivate key path
passwordNo-SSH password
strict_host_keyNotrueEnable host key verification
known_host_fileNo~/.ssh/known_hostsKnown hosts file path
timeoutNo30sConnection timeout
directionNouploadupload or download
sourceYes-Source path (local for upload, remote for download)
destinationYes-Destination path (remote for upload, local for download)
bastionNo-Bastion host configuration (same as SSH)

The SSH timeout field limits connection establishment. DAG-level and step-level timeout_sec cover connection setup and the complete transfer. When execution is canceled or reaches either deadline, Dagu closes the SSH transport so blocked uploads and downloads can finish promptly.

Directory Transfer

Directories are transferred recursively:

yaml
steps:
  - id: upload_dir
    action: sftp.upload
    with:
      source: /local/project/
      destination: /remote/project/

  - id: download_dir
    action: sftp.download
    with:
      source: /remote/backup/
      destination: /local/backup/

Atomic Uploads

Uploads write to a temporary file (.dagu-tmp-{random}) and then rename it to the final destination. This prevents incomplete files if an upload fails.

See Also

  • SSH - Remote command execution
  • S3 - S3 file operations

Dagu is open source under the GNU General Public License v3.0.