Restic-Backup-Skript für Gitlab-Docker mit Omnibus

English Deutsch

Hinweis: Verwandte Beiträge:

Konfigurieren des Backup-Skripts

Generieren Sie zuerst das Verschlüsselungspasswort mit

generate_restic_password.sh
pwgen 30 > .restic_password

Stellen Sie sicher, dass Sie dieses Passwort separat sichern oder ALLE IHRE DATEN GEHEN VERLOREN!

Erstellen Sie nun backup.sh im selben Verzeichnis wie docker-compose.yml:

gitlab_backup.sh
#!/bin/bash
export NAME=$(basename $(pwd))
export RESTIC_REPOSITORY=rest:http://restic:[email protected]:16383/$NAME
export RESTIC_PASSWORD_FILE=.restic_password


if [ ! -f "${RESTIC_PASSWORD_FILE}" ]; then
   echo "Please create .restic_password with the backup encryption password AND BACKUP THAT PASSWORD SEPARATELY!!!"
   exit 1
fi
echo "Initing repo, please ignore any 'already exists' errors"
if [ ! -f ".restic_inited" ]; then
    # Run the restic init command
    restic init

    if [ $? -eq 0 ]; then # if init successful
        # Create the initialization file
        touch ".restic_inited"
        echo "Restic initialized"
    fi
fi

# Save Gitlab-internal PostgreSQL
docker-compose exec -u gitlab-psql gitlab pg_dump -h /var/opt/gitlab/postgresql/ -d gitlabhq_production |  restic --verbose backup --stdin --stdin-filename="$NAME-pgdump.sql"
# Save directories
restic --verbose backup config data index backup.sh docker-compose.yml --exclude=data/gitlab-rails/shared/artifacts/ --exclude=data/postgresql

Automatisches Starten des Backup-Skripts

Siehe How To Create A Systemd Backup Timer & Service In 10 Seconds

TL;DR: Führen Sie im Verzeichnis, in dem sich backup.sh befindet, aus

create_backup_service.sh
wget -qO- https://techoverflow.net/scripts/create-backup-service.sh | sudo bash /dev/stdin

Check out similar posts by category: Restic, Backup, GitLab