mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
add flag to bypass space check (#2265)
This commit is contained in:
parent
00ef2380e5
commit
f987009406
2 changed files with 13 additions and 10 deletions
|
|
@ -33,5 +33,6 @@ Backs up a FeatureBase server to a local, tar-formatted snapshot file.
|
|||
ctl.SetTLSConfig(flags, "", &cmd.TLS.CertificatePath, &cmd.TLS.CertificateKeyPath, &cmd.TLS.CACertPath, &cmd.TLS.SkipVerify, &cmd.TLS.EnableClientVerification)
|
||||
flags.StringVar(&cmd.AuthToken, "auth-token", "", "Authentication token")
|
||||
flags.StringVar(&cmd.HeaderTimeoutStr, "header-timeout", cmd.HeaderTimeoutStr, "Length of time to wait for initial HTTP response before giving up.")
|
||||
flags.BoolVar(&cmd.IgnoreSpaceCheck, "ignore-space-check", false, "Disable disk space check")
|
||||
return ccmd
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ type BackupCommand struct { // nolint: maligned
|
|||
|
||||
TLS server.TLSConfig
|
||||
|
||||
AuthToken string
|
||||
AuthToken string
|
||||
IgnoreSpaceCheck bool
|
||||
}
|
||||
|
||||
// NewBackupCommand returns a new instance of BackupCommand.
|
||||
|
|
@ -141,13 +142,15 @@ func (cmd *BackupCommand) Run(ctx context.Context) (err error) {
|
|||
// Ensure output directory doesn't exist; then create output directory.
|
||||
if _, err := os.Stat(cmd.OutputDir); !os.IsNotExist(err) {
|
||||
return fmt.Errorf("output directory already exists")
|
||||
} else if err := os.MkdirAll(cmd.OutputDir, 0750); err != nil {
|
||||
} else if err := os.MkdirAll(cmd.OutputDir, 0o750); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Ensure there is enough free space
|
||||
if err := cmd.checkFreeSpace(ctx); err != nil {
|
||||
return fmt.Errorf("not enough disk space available: %w", err)
|
||||
if !cmd.IgnoreSpaceCheck {
|
||||
// Ensure there is enough free space
|
||||
if err := cmd.checkFreeSpace(ctx); err != nil {
|
||||
return fmt.Errorf("not enough disk space available: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Backup schema.
|
||||
|
|
@ -192,7 +195,7 @@ func (cmd *BackupCommand) backupSchema(ctx context.Context, schema *pilosa.Schem
|
|||
return fmt.Errorf("marshaling schema: %w", err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(filepath.Join(cmd.OutputDir, "schema"), buf, 0600); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(cmd.OutputDir, "schema"), buf, 0o600); err != nil {
|
||||
return fmt.Errorf("writing schema: %w", err)
|
||||
}
|
||||
|
||||
|
|
@ -333,14 +336,13 @@ func (cmd *BackupCommand) backupShardNode(ctx context.Context, indexName string,
|
|||
pilosa.WithClientRetryPeriod(cmd.RetryPeriod),
|
||||
pilosa.WithSerializer(proto.Serializer{}))
|
||||
rc, err := client.ShardReader(ctx, indexName, shard)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("fetching shard reader: %w", err)
|
||||
}
|
||||
defer rc.Close()
|
||||
|
||||
filename := filepath.Join(cmd.OutputDir, "indexes", indexName, "shards", fmt.Sprintf("%04d", shard))
|
||||
if err := os.MkdirAll(filepath.Dir(filename), 0750); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(filename), 0o750); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -398,7 +400,7 @@ func (cmd *BackupCommand) backupIndexPartitionTranslateData(ctx context.Context,
|
|||
defer rc.Close()
|
||||
|
||||
filename := filepath.Join(cmd.OutputDir, "indexes", name, "translate", fmt.Sprintf("%04d", partitionID))
|
||||
if err := os.MkdirAll(filepath.Dir(filename), 0750); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(filename), 0o750); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -427,7 +429,7 @@ func (cmd *BackupCommand) backupFieldTranslateData(ctx context.Context, indexNam
|
|||
defer rc.Close()
|
||||
|
||||
filename := filepath.Join(cmd.OutputDir, "indexes", indexName, "fields", fieldName, "translate")
|
||||
if err := os.MkdirAll(filepath.Dir(filename), 0750); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(filename), 0o750); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue