Pārlūkot izejas kodu

Backup gitea from docker

test
Julien Toscano pirms 4 gadiem
vecāks
revīzija
40abd112fd
1 mainītis faili ar 23 papildinājumiem un 0 dzēšanām
  1. +23
    -0
      backup/backup_gitea

+ 23
- 0
backup/backup_gitea Parādīt failu

@@ -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 {} \;

Notiek ielāde…
Atcelt
Saglabāt