mirror of https://github.com/restic/restic.git
Merge c074dd4692
into faffd15d13
This commit is contained in:
commit
09d2eabb94
|
@ -0,0 +1,9 @@
|
|||
Enhancement: allow customizing MaxConcurrentRequestsPerFile and MaxPacket parameters in the sftp backend
|
||||
|
||||
SFTP over long fat links suffers from poor performance due to its by default
|
||||
overly small max payload size. But implementations such as OpenSSH tend to
|
||||
accept vastly bigger packets, which improves backup performance for this
|
||||
kind of situation. Restic now allows customizing the max packet size and
|
||||
max concurrent requests per file parameters in the sftp backend.
|
||||
|
||||
https://github.com/restic/restic/pull/4445
|
|
@ -17,13 +17,17 @@ type Config struct {
|
|||
Command string `option:"command" help:"specify command to create sftp connection"`
|
||||
Args string `option:"args" help:"specify arguments for ssh"`
|
||||
|
||||
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
|
||||
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
|
||||
MaxConcurrentRequestsPerFile int `option:"max_concurrent_requests_per_file" help:"sets the maximum concurrent requests allowed for a single file (default: 64)"`
|
||||
MaxPacket int `option:"max_packet" help:"sets the maximum size of the payload, measured in bytes (default: 32768)"`
|
||||
}
|
||||
|
||||
// NewConfig returns a new config with default options applied.
|
||||
func NewConfig() Config {
|
||||
return Config{
|
||||
Connections: 5,
|
||||
Connections: 5,
|
||||
MaxConcurrentRequestsPerFile: 64,
|
||||
MaxPacket: 32768,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,10 @@ func startClient(cfg Config) (*SFTP, error) {
|
|||
}()
|
||||
|
||||
// open the SFTP session
|
||||
client, err := sftp.NewClientPipe(rd, wr)
|
||||
client, err := sftp.NewClientPipe(rd, wr,
|
||||
sftp.MaxConcurrentRequestsPerFile(cfg.MaxConcurrentRequestsPerFile),
|
||||
sftp.MaxPacketUnchecked(cfg.MaxPacket),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("unable to start the sftp session, error: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue