Compare commits
3 commits
main
...
forgejo_ba
Author | SHA1 | Date | |
---|---|---|---|
2d034b4d6d | |||
5cdb7cf942 | |||
7eea729fd5 |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
||||||
|
.gitignore
|
||||||
|
.gitconfig
|
||||||
*.env
|
*.env
|
||||||
*.log
|
*.log
|
||||||
|
|
20
README.md
20
README.md
|
@ -1,20 +0,0 @@
|
||||||
# Backup Scripts
|
|
||||||
|
|
||||||
This repository contains scripts to back up various applications. The primary script, `full-backup.sh`, coordinates the backup process by invoking individual backup scripts for each application.
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
### Main Scripts
|
|
||||||
|
|
||||||
- **full-backup.sh**
|
|
||||||
- Orchestrates the backup process for all applications listed in its internal array. To add a new application, simply include its name in the array.
|
|
||||||
- **logger.sh**
|
|
||||||
- Provides logging functionality to ensure all backup processes are logged.
|
|
||||||
|
|
||||||
### Application Backup Scripts
|
|
||||||
|
|
||||||
Each application has its own directory containing:
|
|
||||||
- Backup script
|
|
||||||
- Environment variables file (`.env`)
|
|
||||||
- Log file (created on the first run)
|
|
||||||
|
|
45
forgejo/forgejo-backup.sh
Executable file
45
forgejo/forgejo-backup.sh
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
SCRIPT_ABS_LOCATION=$(realpath "$(dirname "${0}")")
|
||||||
|
|
||||||
|
source $SCRIPT_ABS_LOCATION/forgejo-backup.env
|
||||||
|
source $SCRIPT_ABS_LOCATION/../logger.sh
|
||||||
|
|
||||||
|
# Container Names
|
||||||
|
APP_CONTAINER="forgejo"
|
||||||
|
BACKUP_CONTAINER="duplicati"
|
||||||
|
|
||||||
|
SOURCE_DIR="/mnt/data/forgejo"
|
||||||
|
BACKUP_DESTINATION="$BACKUP_DESTINATION"
|
||||||
|
BACKUP_ENCR_PASSPHRASE="$BACKUP_ENCR_PASSPHRASE"
|
||||||
|
|
||||||
|
# Cloud Storage Authentication
|
||||||
|
SFTP_USERNAME="$SFTP_USERNAME"
|
||||||
|
SFTP_PASSWORD="$SFTP_PASSWORD"
|
||||||
|
SFTP_FINGERPRINT="$SFTP_FINGERPRINT"
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
LOG_FILE="$SCRIPT_ABS_LOCATION/forgejo-backup.log"
|
||||||
|
|
||||||
|
# Stop forgejo container
|
||||||
|
log "Stopping forgejo container..."
|
||||||
|
docker stop $APP_CONTAINER || { log "Error: Failed to stop forgejo."; exit 1; }
|
||||||
|
|
||||||
|
# Backup all files to target destination
|
||||||
|
log "Backing up forgejo files (including the SQLite database)..."
|
||||||
|
docker exec $BACKUP_CONTAINER \
|
||||||
|
duplicati-cli backup \
|
||||||
|
ssh://$BACKUP_DESTINATION \
|
||||||
|
$SOURCE_DIR \
|
||||||
|
--backup-name="forgejo backup" \
|
||||||
|
--keep-versions=7 \
|
||||||
|
--auth-username=$SFTP_USERNAME \
|
||||||
|
--auth-password=$SFTP_PASSWORD \
|
||||||
|
--passphrase=$BACKUP_ENCR_PASSPHRASE \
|
||||||
|
--ssh-fingerprint="$SFTP_FINGERPRINT" \
|
||||||
|
--prefix="forgejo" || { log "Error: Failed to backup forgejo files and database."; exit 1; }
|
||||||
|
|
||||||
|
# Turn off Maintenance Mode
|
||||||
|
log "Starting forgejo container..."
|
||||||
|
docker start $APP_CONTAINER || { log "Error: Failed to start forgejo container."; exit 1; }
|
||||||
|
|
||||||
|
log "Forgejo backup completed successfully."
|
|
@ -3,7 +3,7 @@
|
||||||
SCRIPT_ABS_LOCATION=$(realpath "$(dirname "${0}")")
|
SCRIPT_ABS_LOCATION=$(realpath "$(dirname "${0}")")
|
||||||
|
|
||||||
# Define an array of application names
|
# Define an array of application names
|
||||||
declare -a apps=("cryptpad" "immich" "duplicati" "nextcloud" "vaultwarden")
|
declare -a apps=("cryptpad" "immich" "duplicati" "nextcloud" "vaultwarden" "forgejo" "portainer")
|
||||||
|
|
||||||
# Function to execute the backup script for each application
|
# Function to execute the backup script for each application
|
||||||
backup_app() {
|
backup_app() {
|
||||||
|
|
45
portainer/portainer-backup.sh
Executable file
45
portainer/portainer-backup.sh
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
SCRIPT_ABS_LOCATION=$(realpath "$(dirname "${0}")")
|
||||||
|
|
||||||
|
source $SCRIPT_ABS_LOCATION/portainer-backup.env
|
||||||
|
source $SCRIPT_ABS_LOCATION/../logger.sh
|
||||||
|
|
||||||
|
# Container Names
|
||||||
|
APP_CONTAINER="portainer"
|
||||||
|
BACKUP_CONTAINER="duplicati"
|
||||||
|
|
||||||
|
SOURCE_DIR="/volumes/portainer"
|
||||||
|
BACKUP_DESTINATION="$BACKUP_DESTINATION"
|
||||||
|
BACKUP_ENCR_PASSPHRASE="$BACKUP_ENCR_PASSPHRASE"
|
||||||
|
|
||||||
|
# Cloud Storage Authentication
|
||||||
|
SFTP_USERNAME="$SFTP_USERNAME"
|
||||||
|
SFTP_PASSWORD="$SFTP_PASSWORD"
|
||||||
|
SFTP_FINGERPRINT="$SFTP_FINGERPRINT"
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
LOG_FILE="$SCRIPT_ABS_LOCATION/portainer-backup.log"
|
||||||
|
|
||||||
|
# Stop portainer container
|
||||||
|
log "Stopping portainer container..."
|
||||||
|
docker stop $APP_CONTAINER || { log "Error: Failed to stop portainer."; exit 1; }
|
||||||
|
|
||||||
|
# Backup all files to target destination
|
||||||
|
log "Backing up portainer files (including the SQLite database)..."
|
||||||
|
docker exec $BACKUP_CONTAINER \
|
||||||
|
duplicati-cli backup \
|
||||||
|
ssh://$BACKUP_DESTINATION \
|
||||||
|
$SOURCE_DIR \
|
||||||
|
--backup-name="portainer backup" \
|
||||||
|
--keep-versions=7 \
|
||||||
|
--auth-username=$SFTP_USERNAME \
|
||||||
|
--auth-password=$SFTP_PASSWORD \
|
||||||
|
--passphrase=$BACKUP_ENCR_PASSPHRASE \
|
||||||
|
--ssh-fingerprint="$SFTP_FINGERPRINT" \
|
||||||
|
--prefix="portainer" || { log "Error: Failed to backup portainer files and database."; exit 1; }
|
||||||
|
|
||||||
|
# Turn off Maintenance Mode
|
||||||
|
log "Starting portainer container..."
|
||||||
|
docker start $APP_CONTAINER || { log "Error: Failed to start portainer container."; exit 1; }
|
||||||
|
|
||||||
|
log "portainer backup completed successfully."
|
Loading…
Reference in a new issue