Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tuladhar/k8s-backup-mongodb
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: codex-team/k8s-backup-mongodb
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 6 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 22, 2022

  1. Copy the full SHA
    0957b56 View commit details
  2. pin mongodb version

    nikmel2803 committed Jul 22, 2022
    Copy the full SHA
    86b9b30 View commit details
  3. Copy the full SHA
    a80cac6 View commit details
  4. Copy the full SHA
    d566077 View commit details
  5. change date format

    nikmel2803 committed Jul 22, 2022
    Copy the full SHA
    3789721 View commit details
  6. fix cicd

    nikmel2803 committed Jul 22, 2022
    Copy the full SHA
    61d2f5d View commit details
Showing with 54 additions and 4 deletions.
  1. +47 −0 .github/workflows/release.yaml
  2. +2 −2 Dockerfile
  3. +5 −2 backup-mongodb.sh
47 changes: 47 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and push Docker image

on:
push:
branches:
- '*'
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-20.04

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value={{branch}}-{{sha}}-{{date 'X'}},enable=${{ startsWith(github.ref, 'refs/heads') }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push image
uses: docker/build-push-action@v3
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ startsWith(github.ref, 'refs/tags/v') || endsWith(github.ref, '/stage') }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM mongo:latest
FROM mongo:5.0.9

RUN apt update && \
apt install awscli p7zip-full -y
apt install awscli p7zip-full curl -y

WORKDIR /scripts

7 changes: 5 additions & 2 deletions backup-mongodb.sh
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
set -e

SCRIPT_NAME=backup-mongodb
ARCHIVE_NAME=mongodump_$(date +%Y%m%d_%H%M%S).gz
ARCHIVE_NAME=mongodump_${BACKUP_NAME}_$(date +"%Y-%m-%d_%H-%M-%S").gz
OPLOG_FLAG=""

if [ -n "$MONGODB_OPLOG" ]; then
@@ -20,7 +20,7 @@ mongodump $OPLOG_FLAG \
COPY_NAME=$ARCHIVE_NAME
if [ ! -z "$PASSWORD_7ZIP" ]; then
echo "[$SCRIPT_NAME] 7Zipping with password..."
COPY_NAME=mongodump_$(date +%Y%m%d_%H%M%S).7z
COPY_NAME=mongodump_${BACKUP_NAME}_$(date +"%Y-%m-%d_%H-%M-%S").7z
7za a -tzip -p"$PASSWORD_7ZIP" -mem=AES256 "$COPY_NAME" "$ARCHIVE_NAME"
fi

@@ -38,3 +38,6 @@ rm "$COPY_NAME"
rm "$ARCHIVE_NAME" || true

echo "[$SCRIPT_NAME] Backup complete!"

curl -X POST -d "message=Backup created: $ARCHIVE_NAME" $NOTIFICATION_URL