sftp put overwrite existing folder

Hi, I like to upload a folder to my volume, I managed to access the directory, but I am not able to “put” a folder to sftp, how can I upload and overwrite existing folder?

» put /users/jimmychen/downloads/content/ /content
put /users/jimmychen/downloads/content/ → /content: file exists on VM

1 Like

I am too would be happy to achieve that with a simple command.

I’ve tried a bunch of workarounds. The approach that worked for me was to use an archiver to pack a folder as a single file. The file then was transferred with sftp and extracted on the server side to a folder.

However, it would be much cooler if sftp shell provided by flyctl command could handle folders natively without jumping through the hoops.


Hi, how do you do this with fly?thanks

The SFTP shell of flyctl isn’t very powerful, it can’t upload directories at all (yet). Some workarounds:

  • Create an archive and transfer it as @‍Hypermind suggested. To extract it, you can open a shell using fly ssh console then run the extraction command.

  • Use scp/rsync. Downsides: slightly complex to set up the connection (example), and requires scp/rsync to be installed in the app’s VM.

hi, Thanks for your reply, but I don’t see any unzip option?

under sftp shell, when I type
» unzip content.zip
I can this error message

unrecognized command; try ‘cd’, ‘ls’, ‘get’, ‘put’, or ‘chmod’

Thank you

That’s the SFTP shell. You need to exit out of it and open a regular SSH shell using fly ssh console.

I don’t think unzip will be installed by default (it depends on the image you are using), so I suggest switching to tar (or you can install unzip inside the VM). To create a tar archive, you can use tar or 7-zip.

+1 Yes, It would be better if flyctl SFTP shell put command supports overwritting existing files rather than having to ssh console each time to delete a file.