Complete Restructure and gitea

* Moved common functions
+ Started work on gitea
This commit is contained in:
2024-01-18 19:08:49 +02:00
parent 5c1a416b60
commit b61e4066cb
10 changed files with 181 additions and 39 deletions

0
gitea/README.md Normal file
View File

18
gitea/config.example.sh Normal file
View File

@@ -0,0 +1,18 @@
# The name of the gitea container, this is required.
GITEA_CONTAINER_NAME="gitea_app"
# An absolute path to the gitea app.ini from within the docker container
GITEA_CONF_PATH=/data/gitea/conf/app.ini
# The path where WITHING THE CONTAINER the dump will be placed
GITEA_BACKUP_CONTAINER_LOCATION=/backups
# The path that was mounted for gitea to push backups to
BACKUP_SOURCE_PATH=/home/x/services/gitea/backups
# Define the number of backups to keep (e.g., keep the latest 7 backups)
KEEP_BACKUP_COUNT=3
# Discord Settings
DISCORD_WEBHOOK=
# Google Drive Settings
GOOGLE_DRIVE_FOLDER_ID=

56
gitea/gitea_backup.sh Normal file
View File

@@ -0,0 +1,56 @@
#!/bin/bash
# Preloader
# Determine the directory of the script
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROGRAM_NAME="Gitea Backup Script"
### [ Imports ] ###
# Import Colors
source "$SCRIPT_DIR/../lib/colors.sh"
# Import configuration
source "$SCRIPT_DIR/config.sh"
# Import Functions
source "$SCRIPT_DIR/../lib/functions.sh"
### [ Functions ] ###
backup_from_docker() {
# Reference to the gitea container id
GITEA_DOCKER_CONTAINER=$(docker ps -qf name="${GITEA_CONTAINER_NAME}")
# Run the backup process
if docker exec -w $GITEA_BACKUP_CONTAINER_LOCATION -u git $GITEA_DOCKER_CONTAINER bash -c "/usr/local/bin/gitea dump -c $GITEA_CONF_PATH"; then
log "Gitea backup created successfully."
else
error "Failed to create Gitea backup."
send_discord_notification "Failed to create Gitea backup."
exit 1
fi
# Determine the path to the output file
BACKUP_FILE=$(ls -Art $BACKUP_SOURCE_PATH/gitea-dump-*.zip | tail -n 1)
if [ -z "$BACKUP_FILE" ]; then
error "Backup file not found."
send_discord_notification "Backup file not found."
exit 1
fi
log "Backup file $BACKUP_FILE created."
}
### [ Main ] ###
echo -e "${YELLOW}Starting ${PROGRAM_NAME}...${NC}"
send_discord_notification "Starting Vaultwarden backup..." "16776960" # Yellow color
check_required_programs "$SCRIPT_DIR/required_programs.txt"
backup_from_docker
# Run google drive backup
# Final message
log "Backup process completed."
send_discord_notification "Backup process completed."

8
gitea/gitea_password.sh Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
# Here you can/should run a short script of getting your
# password as plain text, I personally recommend
# gpg key encryption of your key and decrypting it
# at runtime, it really depends on what kind of setup you have
echo -e "example_password";

View File

@@ -0,0 +1,3 @@
docker
*gdrive
*curl