A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/orgrim/pg_back/commit/da152bac3bb32ae0da7e62c23a629b0080035bd6 below:

upload with sftp and fixes on upload S3 · orgrim/pg_back@da152ba · GitHub

@@ -76,7 +76,7 @@ type options struct {

76 76

CipherPassphrase string

77 77

Decrypt bool

78 78 79 -

Upload string // values are none, s3

79 +

Upload string // values are none, s3, sftp

80 80

PurgeRemote bool

81 81

S3Region string

82 82

S3Bucket string

@@ -86,6 +86,14 @@ type options struct {

86 86

S3Secret string

87 87

S3ForcePath bool

88 88

S3DisableTLS bool

89 + 90 +

SFTPHost string

91 +

SFTPPort string

92 +

SFTPUsername string

93 +

SFTPPassword string

94 +

SFTPDirectory string

95 +

SFTPIdentityFile string // path to private key

96 +

SFTPIgnoreKnownHosts bool

89 97

}

90 98 91 99

func defaultOptions() options {

@@ -250,6 +258,14 @@ func parseCli(args []string) (options, []string, error) {

250 258

S3ForcePath := pflag.String("s3-force-path", "no", "force path style addressing instead of virtual hosted bucket\naddressing")

251 259

S3UseTLS := pflag.String("s3-tls", "yes", "enable or disable TLS on requests")

252 260 261 +

pflag.StringVar(&opts.SFTPHost, "sftp-host", "", "Remote hostname for SFTP")

262 +

pflag.StringVar(&opts.SFTPPort, "sftp-port", "", "Remote port for SFTP")

263 +

pflag.StringVar(&opts.SFTPUsername, "sftp-user", "", "Login for SFTP when different than the current user")

264 +

pflag.StringVar(&opts.SFTPPassword, "sftp-password", "", "Password for SFTP or passphrase when identity file is set")

265 +

pflag.StringVar(&opts.SFTPDirectory, "sftp-directory", "", "Target directory on the remote host")

266 +

pflag.StringVar(&opts.SFTPIdentityFile, "sftp-identity", "", "Path to a private key")

267 +

SFTPIgnoreHostKey := pflag.String("sftp-ignore-hostkey", "no", "Check the target host key against local known hosts")

268 + 253 269

pflag.StringVarP(&opts.Host, "host", "h", "", "database server host or socket directory")

254 270

pflag.IntVarP(&opts.Port, "port", "p", 0, "database server port number")

255 271

pflag.StringVarP(&opts.Username, "username", "U", "", "connect as specified database user")

@@ -377,7 +393,7 @@ func parseCli(args []string) (options, []string, error) {

377 393

}

378 394 379 395

// Validate upload option

380 -

stores := []string{"none", "s3"}

396 +

stores := []string{"none", "s3", "sftp"}

381 397

if err := validateEnum(opts.Upload, stores); err != nil {

382 398

return opts, changed, fmt.Errorf("invalid value for --upload: %s", err)

383 399

}

@@ -387,20 +403,25 @@ func parseCli(args []string) (options, []string, error) {

387 403

return opts, changed, fmt.Errorf("invalid value for --purge-remote: %s", err)

388 404

}

389 405 390 -

// Validate S3 options

391 -

opts.S3ForcePath, err = validateYesNoOption(*S3ForcePath)

392 -

if err != nil {

393 -

return opts, changed, fmt.Errorf("invalid value for --s3-force-path: %s", err)

394 -

}

406 +

switch opts.Upload {

407 +

case "s3":

408 +

// Validate S3 options

409 +

opts.S3ForcePath, err = validateYesNoOption(*S3ForcePath)

410 +

if err != nil {

411 +

return opts, changed, fmt.Errorf("invalid value for --s3-force-path: %s", err)

412 +

}

395 413 396 -

S3WithTLS, err := validateYesNoOption(*S3UseTLS)

397 -

if err != nil {

398 -

return opts, changed, fmt.Errorf("invalid value for --s3-tls: %s", err)

399 -

}

400 -

opts.S3DisableTLS = !S3WithTLS

414 +

S3WithTLS, err := validateYesNoOption(*S3UseTLS)

415 +

if err != nil {

416 +

return opts, changed, fmt.Errorf("invalid value for --s3-tls: %s", err)

417 +

}

418 +

opts.S3DisableTLS = !S3WithTLS

401 419 402 -

if opts.Upload == "s3" && opts.S3Bucket == "" {

403 -

return opts, changed, fmt.Errorf("option --s3-bucket is mandatory when --upload=s3")

420 +

case "sftp":

421 +

opts.SFTPIgnoreKnownHosts, err = validateYesNoOption(*SFTPIgnoreHostKey)

422 +

if err != nil {

423 +

return opts, changed, fmt.Errorf("invalid value for --sftp-ignore-hostkey: %s", err)

424 +

}

404 425

}

405 426 406 427

return opts, changed, nil

@@ -457,6 +478,14 @@ func loadConfigurationFile(path string) (options, error) {

457 478

opts.S3ForcePath = s.Key("s3_force_path").MustBool(false)

458 479

opts.S3DisableTLS = !s.Key("s3_tls").MustBool(true)

459 480 481 +

opts.SFTPHost = s.Key("sftp_host").MustString("")

482 +

opts.SFTPPort = s.Key("sftp_port").MustString("")

483 +

opts.SFTPUsername = s.Key("sftp_user").MustString("")

484 +

opts.SFTPPassword = s.Key("sftp_password").MustString("")

485 +

opts.SFTPDirectory = s.Key("sftp_directory").MustString("")

486 +

opts.SFTPIdentityFile = s.Key("sftp_identity").MustString("")

487 +

opts.SFTPIgnoreKnownHosts = s.Key("sftp_ignore_hostkey").MustBool(false)

488 + 460 489

// Validate purge keep and time limit

461 490

keep, err := validatePurgeKeepValue(purgeKeep)

462 491

if err != nil {

@@ -488,15 +517,11 @@ func loadConfigurationFile(path string) (options, error) {

488 517

}

489 518 490 519

// Validate upload option

491 -

stores := []string{"none", "s3"}

520 +

stores := []string{"none", "s3", "sftp"}

492 521

if err := validateEnum(opts.Upload, stores); err != nil {

493 522

return opts, fmt.Errorf("invalid value for upload: %s", err)

494 523

}

495 524 496 -

if opts.Upload == "s3" && opts.S3Bucket == "" {

497 -

return opts, fmt.Errorf("option s3_bucket is mandatory when upload is s3")

498 -

}

499 - 500 525

// Validate the value of the timestamp format. Force the use of legacy

501 526

// on windows to avoid failure when creating filenames with the

502 527

// timestamp

@@ -688,6 +713,21 @@ func mergeCliAndConfigOptions(cliOpts options, configOpts options, onCli []strin

688 713

case "s3-tls":

689 714

opts.S3DisableTLS = cliOpts.S3DisableTLS

690 715 716 +

case "sftp-host":

717 +

opts.SFTPHost = cliOpts.SFTPHost

718 +

case "sftp-port":

719 +

opts.SFTPPort = cliOpts.SFTPPort

720 +

case "sftp-user":

721 +

opts.SFTPUsername = cliOpts.SFTPUsername

722 +

case "sftp-password":

723 +

opts.SFTPPassword = cliOpts.SFTPPassword

724 +

case "sftp-directory":

725 +

opts.SFTPDirectory = cliOpts.SFTPDirectory

726 +

case "sftp-identity":

727 +

opts.SFTPIdentityFile = cliOpts.SFTPIdentityFile

728 +

case "sftp-ignore-hostkey":

729 +

opts.SFTPIgnoreKnownHosts = cliOpts.SFTPIgnoreKnownHosts

730 + 691 731

case "host":

692 732

opts.Host = cliOpts.Host

693 733

case "port":


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4