From 6eb1a808b1b6c4306e8e0f3662893ca929f0f5bf Mon Sep 17 00:00:00 2001 From: Dmitrii Neeman Date: Wed, 29 Jan 2025 15:28:31 +0200 Subject: [PATCH 1/2] APPS-1490-fix-sort-error - fix sorting error - fix documentation --- cmd/asrestore/cmd/root.go | 6 +++--- cmd/asrestore/readme.md | 37 ++++++++++++++++++------------------ cmd/internal/flags/common.go | 6 +++--- internal/util/files_sort.go | 5 ++--- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cmd/asrestore/cmd/root.go b/cmd/asrestore/cmd/root.go index e4fa3901..fda719f4 100644 --- a/cmd/asrestore/cmd/root.go +++ b/cmd/asrestore/cmd/root.go @@ -57,10 +57,10 @@ func NewCmd(appVersion, commitHash string) *cobra.Command { flagsApp: flags.NewApp(), flagsAerospike: asFlags.NewDefaultAerospikeFlags(), flagsClientPolicy: flags.NewClientPolicy(), - flagsCommon: flags.NewCommon(flags.OperationBackup), + flagsCommon: flags.NewCommon(flags.OperationRestore), flagsRestore: flags.NewRestore(), - flagsCompression: flags.NewCompression(flags.OperationBackup), - flagsEncryption: flags.NewEncryption(flags.OperationBackup), + flagsCompression: flags.NewCompression(flags.OperationRestore), + flagsEncryption: flags.NewEncryption(flags.OperationRestore), flagsSecretAgent: flags.NewSecretAgent(), flagsAws: flags.NewAwsS3(), flagsGcp: flags.NewGcpStorage(), diff --git a/cmd/asrestore/readme.md b/cmd/asrestore/readme.md index 226c2d56..fb5fdd8f 100644 --- a/cmd/asrestore/readme.md +++ b/cmd/asrestore/readme.md @@ -60,25 +60,24 @@ Aerospike Client Flags: Restore Flags: -d, --directory string The directory that holds the backup files. Required, unless -o or -e is used. - -n, --namespace string The namespace to be backed up. Required. - -s, --set string The set(s) to be backed up. Accepts comma-separated values with no spaces: 'set1,set2,set3' - If multiple sets are being backed up, filter-exp cannot be used. - If empty, include all sets. - -B, --bin-list string Only include the given bins in the backup. - Accepts comma-separated values with no spaces: 'bin1,bin2,bin3' - If empty include all bins. - -R, --no-records Don't back up any records. - -I, --no-indexes Don't back up any indexes. - --no-udfs Don't back up any UDFs. - -w, --parallel int Maximum number of scan calls to run in parallel. - If only one partition range is given, or the entire namespace is being backed up, the range - of partitions will be evenly divided by this number to be processed in parallel. Otherwise, each - filter cannot be parallelized individually, so you may only achieve as much parallelism as there are - partition filters. Accepts values from 1-1024 inclusive. (default 1) + -n, --namespace string Used to restore to a different namespace. Example: source-ns,destination-ns + -s, --set string Only restore the given sets from the backup. + Default: restore all sets. + -B, --bin-list string Only restore the given bins in the backup. + If empty, include all bins. + + -R, --no-records Don't restore any records. + Incompatible with --mode=asbx. + -I, --no-indexes Don't restore any secondary indexes. + Incompatible with --mode=asbx. + --no-udfs Don't restore any UDFs. + Incompatible with --mode=asbx. + -w, --parallel int The number of restore threads. Accepts values from 1-1024 inclusive. + If not set the default value is automatically calculated and appears as the number of CPUs on your machine. -L, --records-per-second int Limit total returned records per second (rps). Do not apply rps limit if records-per-second is zero. --max-retries int Maximum number of retries before aborting the current transaction. (default 5) - --total-timeout int Total transaction timeout in milliseconds. 0 - no timeout. + --total-timeout int Total transaction timeout in milliseconds. 0 - no timeout. (default 10000) --socket-timeout int Socket timeout in milliseconds. If this value is 0, it's set to --total-timeout. If both this and --total-timeout are 0, there is no socket idle time limit. (default 10000) -N, --nice int The limits for read/write storage bandwidth in MiB/s @@ -157,13 +156,15 @@ Restore Flags: asbx - restore only .asbx backup files. (default "auto") Compression Flags: - -z, --compress string Enables compressing of backup files using the specified compression algorithm. + -z, --compress string Enables decompressing of backup files using the specified compression algorithm. + This must match the compression mode used when backing up the data. Supported compression algorithms are: zstd, none Set the zstd compression level via the --compression-level option. (default "NONE") --compression-level int zstd compression level. (default 3) Encryption Flags: - --encrypt string Enables encryption of backup files using the specified encryption algorithm. + --encrypt string Enables decryption of backup files using the specified encryption algorithm. + This must match the encryption mode used when backing up the data. Supported encryption algorithms are: none, aes128, aes256. A private key must be given, either via the --encryption-key-file option or the --encryption-key-env option or the --encryption-key-secret. diff --git a/cmd/internal/flags/common.go b/cmd/internal/flags/common.go index 7c89fe0a..848501b2 100644 --- a/cmd/internal/flags/common.go +++ b/cmd/internal/flags/common.go @@ -41,13 +41,13 @@ const ( "If empty, include all bins.\n" descNoRecordsBackup = "Don't back up any records." - descNoRecordsRestore = "Don't restore any records." + descNoRecordsRestore = "Don't restore any records.\nIncompatible with --mode=asbx." descNoIndexesBackup = "Don't back up any indexes." - descNoIndexesRestore = "Don't restore any secondary indexes." + descNoIndexesRestore = "Don't restore any secondary indexes.\nIncompatible with --mode=asbx." descNoUDFsBackup = "Don't back up any UDFs." - descNoUDFsRestore = "Don't restore any UDFs." + descNoUDFsRestore = "Don't restore any UDFs.\nIncompatible with --mode=asbx." descParallelBackup = "Maximum number of scan calls to run in parallel.\n" + "If only one partition range is given, or the entire namespace is being backed up, the range\n" + diff --git a/internal/util/files_sort.go b/internal/util/files_sort.go index 54eb66d3..8ef86e17 100644 --- a/internal/util/files_sort.go +++ b/internal/util/files_sort.go @@ -54,7 +54,8 @@ func SortBackupFiles(files []string) ([]string, error) { } // Prepare strings for sorting. - presort := make([][]backupFile, len(files)) + presort := make(map[int][]backupFile) + maxPrefix := 0 for _, file := range files { @@ -69,8 +70,6 @@ func SortBackupFiles(files []string) ([]string, error) { presort[f.prefix] = append(presort[f.prefix], f) } - // Trim nils. - presort = presort[:maxPrefix+1] // sort each group. for o := range presort { From b3ecdf4d7c08768d4011cd114bb0d98055c9eade Mon Sep 17 00:00:00 2001 From: Dmitrii Neeman Date: Wed, 29 Jan 2025 15:48:00 +0200 Subject: [PATCH 2/2] APPS-1490-fix-sort-error - removed unused code --- internal/util/files_sort.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/internal/util/files_sort.go b/internal/util/files_sort.go index 8ef86e17..2cabc294 100644 --- a/internal/util/files_sort.go +++ b/internal/util/files_sort.go @@ -56,17 +56,11 @@ func SortBackupFiles(files []string) ([]string, error) { // Prepare strings for sorting. presort := make(map[int][]backupFile) - maxPrefix := 0 - for _, file := range files { f, err := parseFileName(file) if err != nil { return nil, fmt.Errorf("failed to parse file name: %s", file) } - // Set max prefix. - if f.prefix > maxPrefix { - maxPrefix = f.prefix - } presort[f.prefix] = append(presort[f.prefix], f) }