Skip to content

Commit ea041e9

Browse files
authored
Merge pull request #2 from cockroachlabs-field/sr8_db
db: add utilities for database backup and restore
2 parents 061e5c5 + 1a39408 commit ea041e9

23 files changed

+1465
-0
lines changed

.github/docker-compose.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright 2025 Cockroach Labs, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
services:
16+
17+
cockroachdb-v24.3:
18+
profiles: ["v24.3"]
19+
image: cockroachdb/cockroach:latest-v24.3
20+
entrypoint: /cockroach/cockroach
21+
command: start-single-node --insecure --store type=mem,size=2G
22+
network_mode: host
23+
24+
cockroachdb-v25.1:
25+
profiles: ["v25.1"]
26+
image: cockroachdb/cockroach:latest-v25.1
27+
entrypoint: /cockroach/cockroach
28+
command: start-single-node --insecure --store type=mem,size=2G
29+
network_mode: host
30+
31+
cockroachdb-v25.2:
32+
profiles: ["v25.2"]
33+
image: cockroachdb/cockroach:latest-v25.2
34+
entrypoint: /cockroach/cockroach
35+
command: start-single-node --insecure --store type=mem,size=2G
36+
network_mode: host
37+
38+
minio:
39+
image: minio/minio
40+
healthcheck:
41+
test: ["CMD", "curl", "--fail", "http://localhost:29001/"]
42+
interval: 30s
43+
timeout: 10s
44+
retries: 3
45+
start_period: 5s
46+
command: server --console-address ":29001" --address ":29000" /data
47+
network_mode: host
48+
environment:
49+
- MINIO_ROOT_USER=cockroach
50+
- MINIO_ROOT_PASSWORD=cockroach
51+
create_bucket:
52+
image: quay.io/minio/mc:RELEASE.2025-03-12T17-29-24Z
53+
depends_on:
54+
minio:
55+
condition: service_healthy
56+
network_mode: host
57+
environment:
58+
- MINIO_ROOT_USER=cockroach
59+
- MINIO_ROOT_PASSWORD=cockroach
60+
entrypoint: >
61+
/bin/sh -c "
62+
/usr/bin/mc alias set dockerminio http://localhost:29000 $$MINIO_ROOT_USER $$MINIO_ROOT_PASSWORD;
63+
/usr/bin/mc mb dockerminio/test;
64+
exit 0;
65+
"

.github/workflows/go-build.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright 2025 Cockroach Labs, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: blobcheck build
16+
run-name: blobcheck build run
17+
on:
18+
workflow_call:
19+
workflow_dispatch:
20+
jobs:
21+
go-build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- id: setup_go
27+
name: Set up Go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version-file: 'go.mod'
31+
32+
- id: install_tools
33+
run: scripts/installTools.sh
34+
35+
- id: build-linux-amd64
36+
run: GOOS=linux GOARCH=amd64 go build -o blobcheck-linux-amd64 .
37+
38+
- id: build-linux-arm
39+
run: GOOS=linux GOARCH=arm64 go build -o blobcheck-linux-arm64 .
40+
41+
- id: build-macos-arm
42+
run: GOOS=darwin GOARCH=arm64 go build -o blobcheck-darwin-arm64 .
43+
44+
- name: Upload artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: blobcheck-linux-amd64
48+
path: blobcheck-linux-amd64
49+
50+
- name: Upload artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: blobcheck-linux-arm64
54+
path: blobcheck-linux-arm64
55+
56+
- name: Upload artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: blobcheck-darwin-arm64
60+
path: blobcheck-darwin-arm64

.github/workflows/go-lint.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2025 Cockroach Labs, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: blobcheck test
16+
run-name: blobcheck build run
17+
on:
18+
workflow_call:
19+
workflow_dispatch:
20+
jobs:
21+
go-lints:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- id: setup_go
27+
name: Set up Go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version-file: 'go.mod'
31+
32+
- id: install_tools
33+
run: scripts/installTools.sh
34+
35+
- id: lint
36+
name: Lints
37+
run: scripts/lints.sh
38+

.github/workflows/go-test.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2025 Cockroach Labs, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: blobcheck test
16+
run-name: blobcheck build run
17+
on:
18+
workflow_call:
19+
workflow_dispatch:
20+
jobs:
21+
go-test:
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 15
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
# These are our primary supported versions.
29+
- id: v25.2
30+
cockroachdb: v25.2
31+
- id: v25.1
32+
cockroachdb: v25.1
33+
- id: v24.3
34+
cockroachdb: v24.3
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- id: start_services
40+
name: start services
41+
working-directory: .github
42+
run: docker compose --profile ${{ matrix.cockroachdb }} up -d
43+
44+
- id: setup_go
45+
name: Set up Go
46+
uses: actions/setup-go@v5
47+
with:
48+
go-version-file: 'go.mod'
49+
50+
- id: install_tools
51+
run: scripts/installTools.sh
52+
53+
- id: run_tests
54+
run: go test ./... --race

.github/workflows/go.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2025 Cockroach Labs, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: blobcheck Build
16+
run-name: blobcheck build
17+
on:
18+
push:
19+
tags: [ 'v*.*.*' ]
20+
pull_request:
21+
jobs:
22+
go-test:
23+
uses: ./.github/workflows/go-test.yaml
24+
go-lints:
25+
uses: ./.github/workflows/go-lint.yaml
26+
go-build:
27+
uses: ./.github/workflows/go-build.yaml

.github/workflows/release.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2025 Cockroach Labs, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Release build
16+
on:
17+
release:
18+
types:
19+
- created
20+
jobs:
21+
build:
22+
uses: ./.github/workflows/go-build.yaml
23+
upload-asset:
24+
needs: build
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Download artifact
28+
uses: actions/download-artifact@v4
29+
with:
30+
name: blobcheck-linux-amd64
31+
- name: Upload asset
32+
uses: actions/upload-release-asset@v1.0.1
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
with:
36+
upload_url: ${{ github.event.release.upload_url }}
37+
asset_path: blobcheck-linux-amd64
38+
asset_name: blobcheck-${{ github.event.release.tag_name }}-linux-amd64
39+
asset_content_type: binary/octet-stream
40+
41+
- name: Download artifact
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: blobcheck-linux-arm64
45+
- name: Upload asset
46+
uses: actions/upload-release-asset@v1.0.1
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
with:
50+
upload_url: ${{ github.event.release.upload_url }}
51+
asset_path: blobcheck-linux-arm64
52+
asset_name: blobcheck-${{ github.event.release.tag_name }}-linux-arm64
53+
asset_content_type: binary/octet-stream
54+
55+
- name: Download artifact
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: blobcheck-darwin-arm64
59+
- name: Upload asset
60+
uses: actions/upload-release-asset@v1.0.1
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
with:
64+
upload_url: ${{ github.event.release.upload_url }}
65+
asset_path: blobcheck-darwin-arm64
66+
asset_name: blobcheck-${{ github.event.release.tag_name }}-darwin-arm64
67+
asset_content_type: binary/octet-stream

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ go.work.sum
3030
# Editor/IDE
3131
# .idea/
3232
# .vscode/
33+
blobcheck
34+
tmp

0 commit comments

Comments
 (0)