Skip to content

Instantly share code, notes, and snippets.

@fengli320
Forked from bst27/gitea-backup.sh
Created August 29, 2020 07:30
Show Gist options
  • Save fengli320/cdd029b4d1c7d4994d02dc719717b26b to your computer and use it in GitHub Desktop.
Save fengli320/cdd029b4d1c7d4994d02dc719717b26b to your computer and use it in GitHub Desktop.
A Gitea backup script for Docker: It creates a .zip backup of Gitea running inside Docker and moves the backup file to the current working directory.
#!/bin/bash
# This script creates a .zip backup of gitea running inside docker and copies the backup file to the current working directory
echo "Creating gitea backup inside docker containter ..."
docker exec -u git -it -w /tmp $(docker ps -qf "name=gitea_server_1") 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_server_1"):/tmp/gitea-dump.zip /tmp
echo "Removing backup file in container ..."
docker exec -u git -it -w /tmp $(docker ps -qf "name=gitea_server_1") bash -c 'rm /tmp/gitea-dump.zip'
echo "Renaming backup file ..."
BACKUPFILE=gitea-dump-$(date +"%Y%m%d%H%M").zip
mv /tmp/gitea-dump.zip $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