Question - How-to - Move files between two SFTP nodes

Subject:
Trying to move files between two SFTP nodes

Current State:
I am able to list the files in each SFTP servers on nodes

n8n workflow:

Screenshot showing that I can list the content from each SFTP node

Question:
If someone can help to guide on how to download file from SFTP on the left 1st SFTP server and then upload it to the right 2nd SFTP server?

Reason:
On the left 1st SFTP server, I have a cron job that runs and takes backup of a file, and I need that backup stored on secondary storage which is the 2nd SFTP server.

Thanks!

Update:

I did extra reading and I found out that in order to move binary data files between nodes, we should be using a middle-man node (Read Binary Files - n8n Documentation)

So far, I was able to get the download file in the first SFTP server, however, not sure how to upload the file to the second SFTP?

First SFTP server node

Read Binary Files node

Second SFTP server node

Any ideas?

Thanks

HI @ansred,
your Read Binary Files does not really do anything, I think you can remove. In your second SFTP server node you are trying to upload the file using an incomplete filte path.

Can you connect you first SFTP node directly to your second SFTP node and set a full file path?

1 Like

Thanks @marcus you were right, no need for the Read Binary Files node, and it is working fine now. Thanks for the confirmation.

Any idea how to have the download 1st SFTP download all the files in a directory and have the 2nd SFTP server node to upload them there (basically to sync the content in between)?

For example to download all the *.zip files from a directory in SFTP node one and then upload all *.zip files to the SFTP node two?

1 Like

I got it working by using the filename expression as variable to meet the requirement of having the full path.

Not sure though that is the best way to do it? maybe there is a better way to deal with any filename and data type in SFTP (directory and files)?

1 Like

Hey ansred,
your strategy looks good to me. Using list, download and upload with expression for filenames is the straight forward thing to do.

1 Like

Sounds good Thanks for the confirmation @marcus it has been working fine.