-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
127 changed files
with
15,617 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Makefile CI | ||
|
||
on: | ||
push: | ||
branches: [ "main", "v3" ] | ||
pull_request: | ||
branches: [ "main", "v3" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.18.2' | ||
- name: Run Build | ||
run: | | ||
make all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Publish Docker - backup-server | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tags: | ||
description: 'Release Tags' | ||
|
||
jobs: | ||
publish_dockerhub: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.18.10' | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: beclab/backup-server:v${{ github.event.inputs.tags }} | ||
file: Dockerfile | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Publish Docker - sidecar-backup-sync | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tags: | ||
description: 'Release Tags' | ||
|
||
jobs: | ||
publish_dockerhub: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.18.10' | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: true | ||
tags: beclab/sidecar-backup-sync:v${{ github.event.inputs.tags }} | ||
file: Dockerfile.sidecar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Build the manager binary | ||
FROM golang:1.18 as builder | ||
|
||
WORKDIR /workspace | ||
|
||
# Copy the go source | ||
COPY . ./ | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o backup-server cmd/backup-server/main.go | ||
|
||
# Use restic backup tools | ||
FROM restic/restic:0.15.2 as restic | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:debug | ||
WORKDIR / | ||
COPY --from=builder /workspace/backup-server . | ||
COPY --from=restic /usr/bin/restic /usr/bin/restic | ||
|
||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/backup-server apiserver"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Build the manager binary | ||
FROM golang:1.18 as builder | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
|
||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY cmd/ cmd/ | ||
COPY config/ config/ | ||
COPY pkg/ pkg/ | ||
|
||
# Build | ||
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o backup_sync cmd/sidecar/backup_sync.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/base:debug | ||
WORKDIR / | ||
COPY --from=builder /workspace/backup_sync . | ||
|
||
VOLUME [ "/data" ] | ||
|
||
ENTRYPOINT ["/backup_sync"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Terminus License | ||
|
||
## Acceptance | ||
|
||
By using the software, you agree to all of the terms and conditions below. | ||
|
||
## Copyright License | ||
|
||
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations below. | ||
|
||
## Limitations | ||
|
||
You may use or modify the software only for your own internal business purposes or for non-commercial or personal use. You may distribute the software or provide it to others only if you do so free of charge for non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law. | ||
|
||
## Patents | ||
|
||
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company. | ||
|
||
## Notices | ||
|
||
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms. If you modify the software, you must include in any modified copies of the software a prominent notice stating that you have modified the software. | ||
|
||
## No Other Rights | ||
|
||
These terms do not imply any licenses other than those expressly granted in these terms. | ||
|
||
## Termination | ||
|
||
If you use the software in violation of these terms, such use is not licensed, and your license will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your license will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your license to terminate automatically and permanently. | ||
|
||
## No Liability | ||
|
||
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim. | ||
|
||
## Definitions | ||
|
||
The “licensor” is the entity offering these terms. | ||
|
||
The “software” is the software the licensor makes available under these terms, including any portion of it. | ||
|
||
“You” refers to the individual or entity agreeing to these terms. | ||
|
||
“Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. Control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect. | ||
|
||
“Your license” is the license granted to you for the software under these terms. | ||
|
||
“Use” means anything you do with the software requiring your license. | ||
|
||
“Trademark” means trademarks, service marks, and similar rights. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
BINARY ?= backup-server | ||
IMG ?= $(BINARY):0.1.1 | ||
MAIN_GO ?= cmd/backup-server/main.go | ||
|
||
SHELL = /usr/bin/env bash -o pipefail | ||
.SHELLFLAGS = -ec | ||
|
||
.PHONY: all | ||
all: build | ||
|
||
.PHONY: fmt | ||
fmt: | ||
go fmt ./... | ||
|
||
.PHONY: vet | ||
vet: | ||
go vet ./... | ||
|
||
.PHONY: test | ||
test: fmt vet | ||
go test ./... -coverprofile _output/cover.out | ||
|
||
.PHONY: build | ||
build: fmt vet | ||
go build -o _output/$(BINARY) $(MAIN_GO) | ||
|
||
.PHONY: api | ||
api: fmt vet | ||
go run $(MAIN_GO) apiserver | ||
|
||
docker-build: test | ||
docker build -t ${IMG} . | ||
|
||
.PHONY: docker-push | ||
docker-push: | ||
docker push ${IMG} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,76 @@ | ||
# backup-server | ||
|
||
# backup-server | ||
|
||
[](https://github.com/beclab/backup-server/actions/workflows/release.yaml) | ||
|
||
## Description | ||
As part of the system, the backup-server provides functionality for backing up and restoring system and user data. | ||
|
||
## Getting Started | ||
|
||
### How to build | ||
```bash | ||
make | ||
``` | ||
|
||
### Running | ||
Before running backup-server, please make sure that the necessary Kubernetes resources it depends on have been created. The resource files are located at /confg/crds/backup/v1/. | ||
|
||
```bash | ||
kubectl apply -f ./config/crds/backup/v1/ | ||
``` | ||
|
||
1. API Server | ||
```bash | ||
backup-server apiserver --velero-namespace os-system \ | ||
--velero-service-account os-internal \ | ||
--backup-bucket terminus-us-west-1 \ | ||
--backup-key-prefix <userid> | ||
``` | ||
|
||
2. Controller | ||
```bash | ||
backup-server controller --velero-namespace os-system \ | ||
--velero-service-account os-internal \ | ||
--backup-bucket terminus-us-west-1 \ | ||
--backup-key-prefix <userid> \ | ||
--backup-retain-days "30" | ||
``` | ||
|
||
3. VController | ||
```bash | ||
backup-server vcontroller --velero-namespace os-system \ | ||
--velero-service-account os-internal | ||
``` | ||
|
||
4. SicdecarBackupSync | ||
```bash | ||
backup-sync --log-level debug --sync-interval "10" | ||
``` | ||
|
||
|
||
|
||
5. Install Velero | ||
```bash | ||
# create velero backup-location | ||
velero backup-location create terminus-cloud \ | ||
--provider terminus \ | ||
--namespace os-system \ | ||
--prefix "" \ | ||
--bucket terminus-cloud | ||
|
||
|
||
# install velero plugin | ||
velero install \ | ||
--no-default-backup-location \ | ||
--namespace os-system \ | ||
--image beclab/velero:v1.11.1 \ | ||
--use-volume-snapshots=false \ | ||
--no-secret \ | ||
--plugins beclab/velero-plugin-for-terminus:v1.0.1 \ | ||
--wait | ||
``` | ||
|
||
6. Create Backup-Plan | ||
|
||
Create a backup task on the Backup page of the Terminus system Settings. |
Oops, something went wrong.