Skip to content

Commit

Permalink
Merge pull request #22 from eol-uchile/Patch-Matic0
Browse files Browse the repository at this point in the history
Enhancements to Backup Scripts and Docker Image CI.

 - Fixes removeness of `bionic` postgresql repo switching to jammy.
 - Adds dedicated official `mysql` apt sources list.
 - Remove `eolito` from image generation workflow.
  • Loading branch information
fsologureng authored Apr 25, 2024
2 parents 0178682 + e5e28d6 commit 5f84072
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 19 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,24 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag ghcr.io/eol-uchile/backup_container:${GITHUB_SHA}
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to Github Container Registry
if: github.ref == 'refs/heads/master'
run: |
echo "${CR_PAT}" | docker login ghcr.io -u eolito --password-stdin
docker push ghcr.io/eol-uchile/backup_container:${GITHUB_SHA}
env:
CR_PAT: ${{ secrets.CR_PAT }}
docker push ghcr.io/eol-uchile/backup_container:${GITHUB_SHA}
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM ubuntu:18.04
FROM ubuntu:jammy

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y apt-transport-https wget lsb-release gnupg && \
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list && \
wget --quiet -O - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add - && \
echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" >> /etc/apt/sources.list.d/postgresql.list && \
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list && \
wget --quiet -O - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - && \
echo "deb http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main" >> /etc/apt/sources.list.d/postgresql.list && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
echo "deb http://repo.mysql.com/apt/ubuntu bionic mysql-5.7" >> /etc/apt/sources.list.d/mysql.list && \
apt-key adv --keyserver pgp.mit.edu --recv-keys B7B3B788A8D3785C && \
apt-get update && \
apt-get install -y \
mongodb-org-tools \
mongodb-database-tools \
postgresql-client-13 \
mysql-client \
mysql-client=5.7* \
nmap \
unzip && \
rm -rf /var/lib/apt/lists/*
Expand Down
1 change: 1 addition & 0 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ backups=$(echo $2 | sed "s/,/ /g")
for s in $backups; do
echo "Doing $s"
sh /root/scripts/services/$s.sh $folder $outfolder $clean_disk
echo "Done $s"
done;

rm -fr $BASE
4 changes: 1 addition & 3 deletions scripts/services/minio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ openssl aes-256-cbc -md sha256 -salt -out $folder/s3.tar.gz.enc -in $folder/s3.t
rm $folder/s3.tar.gz

echo "Uploading to NAS"

# Copy compressed&encrypted file
rclone copy $folder/s3.tar.gz.enc nas:/share/eol_backup/$PLATFORM_NAME/$remote_folder
echo "Uploaded to NAS"

# Remove compressed&encrypted file
rm -rf $folder/s3.tar.gz.enc

echo "Backup completed"

# Clean or move to mount for recovery
# if [ $3 = 'keep' ]
# then
Expand Down
3 changes: 2 additions & 1 deletion scripts/services/mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ rm $folder/mongodb_edxapp.gz

echo "Uploading to NAS"
rclone copy $folder/mongodb_edxapp.gz.enc nas:/share/eol_backup/$PLATFORM_NAME/$remote_folder
echo "Uploaded to NAS"

if [ $3 = 'keep' ]
then
mkdir -p $HOST_MOUNT/$PLATFORM_NAME/mongodb
mv $folder/mongodb_edxapp.gz.enc $HOST_MOUNT/$PLATFORM_NAME/mongodb
else
rm -rf $folder/mongodb_edxapp.gz.enc
fi
fi
3 changes: 2 additions & 1 deletion scripts/services/mongodb_comments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ rm $folder/mongodb_cs_comment_service.gz

echo "Uploading to NAS"
rclone copy $folder/mongodb_cs_comment_service.gz.enc nas:/share/eol_backup/$PLATFORM_NAME/$remote_folder
echo "Uploaded to NAS"

if [ $3 = 'keep' ]
then
mkdir -p $HOST_MOUNT/$PLATFORM_NAME/mongodb
mv $folder/mongodb_cs_comment_service.gz.enc $HOST_MOUNT/$PLATFORM_NAME/mongodb
else
rm -rf $folder/mongodb_cs_comment_service.gz.enc
fi
fi
3 changes: 2 additions & 1 deletion scripts/services/mongodb_graylog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ rm $folder/mongodb_graylog.gz

echo "Uploading to NAS"
rclone copy $folder/mongodb_graylog.gz.enc nas:/share/eol_backup/$PLATFORM_NAME/$remote_folder
echo "Uploaded to NAS"

if [ $3 = 'keep' ]
then
mkdir -p $HOST_MOUNT/$PLATFORM_NAME/mongodb_graylog
mv $folder/mongodb_graylog.gz.enc $HOST_MOUNT/$PLATFORM_NAME/mongodb_graylog
else
rm -rf $folder/mongodb_graylog.gz.enc
fi
fi
5 changes: 3 additions & 2 deletions scripts/services/mysql.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -eu
set -eu
folder=$1
remote_folder=$2

Expand All @@ -13,11 +13,12 @@ rm $folder/mysql.gz

echo "Uploading to NAS"
rclone copy $folder/mysql.gz.enc nas:/share/eol_backup/$PLATFORM_NAME/$remote_folder
echo "Uploaded to NAS"

if [ $3 = 'keep' ]
then
mkdir -p $HOST_MOUNT/$PLATFORM_NAME/mysql
mv $folder/mysql.gz.enc $HOST_MOUNT/$PLATFORM_NAME/mysql
else
rm -rf $folder/mysql.gz.enc
fi
fi
1 change: 1 addition & 0 deletions scripts/services/postgresql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ then
then
echo "Uploading to NAS"
rclone copy $folder/postgresql.gz.enc nas:/share/eol_backup/$PLATFORM_NAME/$remote_folder
echo "Uploaded to NAS"

# Clean or move to mount for recovery
if [ $3 = 'keep' ]
Expand Down

0 comments on commit 5f84072

Please sign in to comment.