Skip to content

Instantly share code, notes, and snippets.

@seraphyn
Created July 15, 2025 08:39
Show Gist options
  • Save seraphyn/64da93e2b7048b3cf11f583da8196221 to your computer and use it in GitHub Desktop.
Save seraphyn/64da93e2b7048b3cf11f583da8196221 to your computer and use it in GitHub Desktop.
Backup gitea in docker to /var/backups/GiteaBackup. docker container called gitea_prod
#!/bin/bash
echo "Creating gitea backup inside docker containter ..."
docker exec -u git -it -w /tmp $(docker ps -qf "name=gitea_prod") bash -c '/app/gitea/gitea dump -c /data/gitea/conf/app.ini --file /tmp/gitea-dump.zip'
echo "Copying backup file from the container to the host machine ..."
docker cp $(docker ps -qf "name=gitea_prod"):/tmp/gitea-dump.zip /var/backups/GiteaBackup/
echo "Removing backup file in container ..."
docker exec -u git -it -w /tmp $(docker ps -qf "name=gitea_prod") bash -c 'rm /tmp/gitea-dump.zip'
echo "Renaming backup file ..."
BACKUPFILE=gitea-dump-$(date +"%Y%m%d%H%M").zip
mv /var/backups/GiteaBackup/gitea-dump.zip /var/backups/GiteaBackup/$BACKUPFILE
echo "Backup file is available: "$BACKUPFILE
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment