Bash – Progress at fetching large file over sftp

backupbashsftp

I would like to get large file over sftp. I execute following commands:

kopparberg:dev marek$ sftp -P 678 marek@server
marek@server's password: 
Connected to server.
sftp> cd backup
sftp> get database.gz /Volumes/www/backup/
Fetching /backup/database.gz to /Volumes/www/backup/database.gz
                                                  9%   44MB   1.4MB/s   05:06 ETA

Because it follows some more commands, I decided to write a bash script and I put sftp commands in batchfile.

Bash file looks like this:

#!/bin/bash

#get backup file
sftp -P 678 -o "BatchMode no" -b batchfile.sftp marek@server

#following commands
#...

In bacthfile.sftp are just three steps:

cd backup
get database.gz /Volumes/www/backup/
quit

The problem is that I do not see progress when I run the bash file. Is there any rational explanation behind?

Best Answer

Why don't you just use a single SCP command instead?

scp -P 678 marek@server:/backup/database.gz /Volumes/www/backup/

I also believe that using this method will give you the desired output evern when run from a script.