christianspecht / scm-backup

Makes offline backups of your cloud hosted source code repositories
https://scm-backup.org/
GNU General Public License v3.0
58 stars 20 forks source link

Dockerized net8 #78

Closed lessismore-sparkvision closed 1 month ago

lessismore-sparkvision commented 2 months ago

docker run --rm \ -v "${CURRENT_DIR_WIN}/settings.yml:/app/settings.yml" \ -v "${BACKUP_DIR}:/app/backups" \ scmbackup:latest || { echo "ERROR: Failed to start Bitbucket backup."; exit 1; }

Documentation needed.

christianspecht commented 1 month ago

Documentation needed.

Can you elaborate what kind of documentation is needed? (besides the "docker run" command above) I have almost zero Docker experience.

lessismore-sparkvision commented 1 month ago

Little experience to document a Docker app, as well.

It should boil down to 3 things - what I normally look for:

Dockerfile: The Dockerfile was made using Visual Studio and it's now becoming the standard layout for a dockerfile. Earlier, one documented each step in the dockerfile. The link at the top describes the multi-stage build that now is being used: Customize Docker containers..

Build: docker build . --force-rm -t scmbackup:1.8.0 --build-arg BUILD_CONFIGURATION=Debug --label "com.microsoft.created-by=visual-studio" --label "com.microsoft.visual-studio.project-name=ScmBackup"

Run: docker run --rm -v "${CURRENT_DIR_WIN}/settings.yml:/app/settings.yml" -v "${BACKUP_DIR}:/app/backups" scmbackup:1.8.0 || { echo "ERROR: Failed to start Bitbucket backup."; exit 1; }

lessismore-sparkvision commented 1 month ago

Open a terminal and navigate to your project root directory:

cd C:\...\scm-backup

Then run the Docker build command:

docker build -f ./src\/ScmBackup/Dockerfile . --force-rm -t scmbackup:1.8.0 --build-arg BUILD_CONFIGURATION=Debug --label "com.microsoft.created-by=visual-studio" --label "com.microsoft.visual-studio.project-name=ScmBackup"

Explanation: -f ./src/ScmBackup/Dockerfile: Specifies the relative path to the Dockerfile. .: Specifies the build context as the current directory (which should be the root of your project containing the src directory). --force-rm: Forces the removal of intermediate containers after a successful build. -t scmbackup:1.8.0: Tags the image with scmbackup:1.8.0. --build-arg BUILD_CONFIGURATION=Debug: Passes the build argument BUILD_CONFIGURATION with a value of Debug. --label "com.microsoft.created-by=visual-studio": Adds a label to the image indicating it was created by Visual Studio. --label "com.microsoft.visual-studio.project-name=ScmBackup": Adds a label to the image with the project name.

lessismore-sparkvision commented 1 month ago

I am sharing my bash script, which is used to run the backup process. As it's still under development, please use it at your own discretion.

#!/bin/bash

# ***********************************************************************************************
# Backup Bitbucket repos using SCM Backup docker image.
# ***********************************************************************************************

#set -x  # Enable debugging mode
set -e  # Enable exit immediately on error

# Print input variables
echo "Input variables..."
echo ""

# Get current date in YYYY-MM-DD format
CURRENT_DATE=$(date +%Y-%m-%d)
echo "CURRENT DATE: $CURRENT_DATE"

# Get current time in HHMM format without the colon character
CURRENT_TIME=$(date +%H%M)
echo "CURRENT TIME: $CURRENT_TIME"

# Get timestamp as short date and short time
SHORT_DATE_AND_TIME="${CURRENT_DATE}_${CURRENT_TIME}"
echo "SHORT DATE AND TIME: $SHORT_DATE_AND_TIME"

# Get current directory in Windows format
CURRENT_DIR_WIN=$(cygpath -w "$(pwd)")
echo "CURRENT_DIR_WIN: $CURRENT_DIR_WIN"

# Define backup directory path
BACKUP_DIR="${CURRENT_DIR_WIN}\backups\bitbucket_repo_backup_${SHORT_DATE_AND_TIME}"
echo "BACKUP_DIR: $BACKUP_DIR"

# Create the backup directory if it doesn't already exist
mkdir -p "$BACKUP_DIR"

# Run Docker container to perform backup
docker run --rm \
    -v "${CURRENT_DIR_WIN}/settings.yml:/app/settings.yml" \
    -v "${BACKUP_DIR}:/app/backups" \
    scmbackup:1.8.0 || { echo "ERROR: Failed to start Bitbucket backup."; exit 1; }
lessismore-sparkvision commented 1 month ago

Then there is the question if you would like to publicize your Dockerized app and its image. Then you need to use container registry like Docker Hub, GitHub Container Registry, Google Container Registry, or Amazon Elastic Container Registry (ECR). Then, there should be a clear and concise documentation explaining how to use your Dockerized app, which we don't have for the moment.

Anyone else?