Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre- and post-exec commands. #49

Merged
merged 8 commits into from
Aug 25, 2023
3 changes: 3 additions & 0 deletions cmd/internal/database/rethinkdb/rethinkdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ func (db *RethinkDB) Recover() error {
if db.url != "" {
args = append(args, "--connect="+restoreDB.url)
}
if db.passwordFile != "" {
args = append(args, "--password-file="+db.passwordFile)
}
Comment on lines +159 to +161
Copy link
Contributor Author

@Gerrit91 Gerrit91 Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried out the RethinkDB restore and forced the restore by running it manually from the CLI in the backup-restore-sidecar pod.

Before that:

{"level":"info","timestamp":"2023-08-24T13:32:02Z","logger":"rethinkdb","caller":"rethinkdb/rethinkdb.go:120","msg":"starting rethinkdb database within sidecar for restore"}                                                                     
{"level":"info","timestamp":"2023-08-24T13:32:02Z","logger":"rethinkdb","caller":"rethinkdb/rethinkdb.go:130","msg":"waiting for rethinkdb database to come up"}                                                                                  
{"level":"info","timestamp":"2023-08-24T13:32:02Z","logger":"rethinkdb","caller":"probe/probe.go:18","msg":"start probing database"}                                                                                                              
{"level":"info","timestamp":"2023-08-24T13:32:05Z","logger":"rethinkdb","caller":"rethinkdb/rethinkdb.go:150","msg":"rethinkdb in sidecar is now available, now triggering restore commands..."}                                                  
{"level":"info","timestamp":"2023-08-24T13:32:05Z","logger":"rethinkdb","caller":"utils/cmd.go:28","msg":"running command","command":"/usr/local/bin/rethinkdb-restore","args":"--connect=localhost:1 /tmp/backup-restore-sidecar/restore/files/re
thinkdb"}                                                                                                                                                                                                                                         
Error: restoring database was not successful: error running restore command: Usage: rethinkdb restore FILE [-c HOST:PORT] [--tls-cert FILENAME] [-p] [--password-file FILENAME] [--clients NUM] [--shards NUM_SHARDS] [--replicas NUM_REPLICAS] [-
-force] [-i (DB | DB.TABLE)]...                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                  
rethinkdb-restore: error: Unable to connect to server: Could not connect to localhost:1, Wrong password exit status 2

So, I assume it is somehow broken already?

Here is with it:

{"level":"info","timestamp":"2023-08-24T13:42:17Z","logger":"rethinkdb","caller":"rethinkdb/rethinkdb.go:150","msg":"rethinkdb in sidecar is now available, now triggering restore commands..."}
{"level":"info","timestamp":"2023-08-24T13:42:17Z","logger":"rethinkdb","caller":"utils/cmd.go:28","msg":"running command","command":"/usr/local/bin/rethinkdb-restore","args":"--connect=localhost:1 --password-file=/rethinkdb-secret/rethinkdb-password.txt /tmp/backup-restore-sidecar/restore/files/rethinkdb"}
Error: restoring database was not successful: error running restore command: Extracting archive file...
  Done (0 seconds)
Importing from directory...
Error: import failed: The following tables already exist, run with --force to import into the existing tables:
  metalapi.asnpool
  metalapi.asnpoolinfo
  metalapi.event
  metalapi.filesystemlayout
  metalapi.image
  metalapi.integerpool
  metalapi.integerpoolinfo
  metalapi.ip
  metalapi.machine
  metalapi.migration
  metalapi.network
  metalapi.partition
  metalapi.size
  metalapi.sizeimageconstraint
  metalapi.switch
  metalapi.switchstatus exit status 1

I think, it is okay that the restore does not succeed when there is already data present. Not sure if it makes sense to add a --force flag.

args = append(args, rethinkDBRestoreFilePath)

out, err := db.executor.ExecuteCommandWithOutput(rethinkDBRestoreCmd, nil, args...)
Expand Down
Loading