Skip to content

Commit

Permalink
build: add make targets to dump the database (#13771)
Browse files Browse the repository at this point in the history
Signed-off-by: Mason Malone <[email protected]>
  • Loading branch information
MasonM authored Oct 17, 2024
1 parent a88cddc commit e18570c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ git-ask-pass.sh
sdks/python/client/dist/*
/v3/
/cmd/argoexec/commands/test.txt
/db-dumps/

# Do not commit rendered installation manifests since they are misleading to users.
manifests/install.yaml
Expand Down
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,22 @@ endif

.PHONY: postgres-cli
postgres-cli:
kubectl exec -ti `kubectl get pod -l app=postgres -o name|cut -c 5-` -- psql -U postgres
kubectl exec -ti svc/postgres -- psql -U postgres

.PHONY: postgres-dump
postgres-dump:
@mkdir -p db-dumps
kubectl exec svc/postgres -- pg_dump --clean -U postgres > "db-dumps/postgres-$(BUILD_DATE).sql"

.PHONY: mysql-cli
mysql-cli:
kubectl exec -ti `kubectl get pod -l app=mysql -o name|cut -c 5-` -- mysql -u mysql -ppassword argo
kubectl exec -ti svc/mysql -- mysql -u mysql -ppassword argo

.PHONY: mysql-dump
mysql-dump:
@mkdir -p db-dumps
kubectl exec svc/mysql -- mysqldump --no-tablespaces -u mysql -ppassword argo > "db-dumps/mysql-$(BUILD_DATE).sql"


test-cli: ./dist/argo

Expand Down
14 changes: 14 additions & 0 deletions docs/running-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ You'll have, either:
* Postgres on <http://localhost:5432>, run `make postgres-cli` to access.
* MySQL on <http://localhost:3306>, run `make mysql-cli` to access.

To back up the database, use `make postgres-dump` or `make mysql-dump`, which will generate a SQL dump in the `db-dumps/` directory.

```console
make postgres-dump
```

To restore the backup, use `make postgres-cli` or `make mysql-cli`, piping in the file from the `db-dumps/` directory.

Note that this is destructive and will delete any data you have stored.

```console
make postgres-cli < db-dumps/2024-10-16T17:11:58Z.sql
```

To test SSO integration, use `PROFILE=sso`:

```bash
Expand Down

0 comments on commit e18570c

Please sign in to comment.