Este script salva todos os dados do gitea, mas ignora os diretórios actions_artifacts e actions_logs, pois eles podem ser regenerados. Você pode adicionar ou remover exclusões conforme necessário.
Ele é baseado em configuração docker-compose do Gitea com Traefik e PostgreSQL mas pode ser facilmente adaptado a outras configurações.
gitea_restic_backup.sh
#!/bin/bash
export NAME=$(basename $(pwd))
export RESTIC_REPOSITORY=rest:http://restic:abc123abc@10.1.2.3: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 postgres postgres pg_dump -d gitea -U gitea | restic --verbose backup --stdin --stdin-filename="$NAME-pgdump.sql"
# Save directories
restic --verbose backup gitea_config gitea_data backup.sh docker-compose.yml --exclude=gitea_data/actions_artifacts --exclude=gitea_data/actions_logs --exclude=gitea_data/tmpIf this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow