Explorar el Código

Backup gitea from docker

test
Julien Toscano hace 4 años
padre
commit
40abd112fd
Se han modificado 1 ficheros con 23 adiciones y 0 borrados
  1. +23
    -0
      backup/backup_gitea

+ 23
- 0
backup/backup_gitea Ver fichero

@@ -0,0 +1,23 @@
#!/bin/bash

# Variables
BACKUP_ROOT_GITEA="/backup/gitea"
BACKUP_GITEA_RETENTION=10

# Starting backup
echo "Starting gitea backup process ..."

# Backup server configuration
mkdir -p ${BACKUP_ROOT_GITEA}
HOUR=`date +%Y%m%d%H%M`

# Launch dump command on docker
docker exec -w /data $(docker ps -qf "name=gitea") su - git sh -c "/app/gitea/gitea dump -c /data/gitea/conf/app.ini -f gitea-dump-${HOUR}.zip"
# And get from docker
docker cp $(docker ps -qf "name=gitea"):/data/git/gitea-dump-${HOUR}.zip ${BACKUP_ROOT_GITEA}
# Finally, remove backup on container
docker exec -w /data $(docker ps -qf "name=gitea") su - git sh -c "rm gitea-dump-${HOUR}.zip"

# Purge old backup
echo "Starting gitea purge process for backup older than ${BACKUP_GITEA_RETENTION} ..."
find ${BACKUP_ROOT_GITEA} -type f -mtime +${BACKUP_GITEA_RETENTION} -exec rm -f {} \;

Cargando…
Cancelar
Guardar