server-tools !?!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
849 B

  1. #!/bin/bash
  2. # Variables
  3. BACKUP_ROOT_GITEA="/backup/gitea"
  4. BACKUP_GITEA_RETENTION=10
  5. # Starting backup
  6. echo "Starting gitea backup process ..."
  7. # Backup server configuration
  8. mkdir -p ${BACKUP_ROOT_GITEA}
  9. HOUR=`date +%Y%m%d%H%M`
  10. # Launch dump command on docker
  11. 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"
  12. # And get from docker
  13. docker cp $(docker ps -qf "name=gitea"):/data/git/gitea-dump-${HOUR}.zip ${BACKUP_ROOT_GITEA}
  14. # Finally, remove backup on container
  15. docker exec -w /data $(docker ps -qf "name=gitea") su - git sh -c "rm gitea-dump-${HOUR}.zip"
  16. # Purge old backup
  17. echo "Starting gitea purge process for backup older than ${BACKUP_GITEA_RETENTION} ..."
  18. find ${BACKUP_ROOT_GITEA} -type f -mtime +${BACKUP_GITEA_RETENTION} -exec rm -f {} \;