Last active
April 4, 2021 02:35
-
-
Save soulteary/b4c099935d8d0d3487ce9ef5f7eb78cb to your computer and use it in GitHub Desktop.
Gitea data restore script (docker)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Gitea data restore script (docker) | |
# Usage: ./restore.sh gitea-dump-1617385736.zip DockerIdOrDockerName | |
BACKUP_FILE=$1 | |
CONTAINER_NAME=$2 | |
if [ -f "$BACKUP_FILE" ]; then | |
if [ ! -z "$CONTAINER_NAME" -a "$CONTAINER_NAME" != " " ]; then | |
docker cp $BACKUP_FILE $CONTAINER_NAME:/tmp | |
docker exec -it $CONTAINER_NAME unzip /tmp/$BACKUP_FILE -d /tmp/ | |
docker exec -it $CONTAINER_NAME rm -rf /data/gitea | |
docker exec -it $CONTAINER_NAME rm -rf /data/git/repositories | |
docker exec -it $CONTAINER_NAME mv /tmp/data /data/gitea | |
docker exec -it $CONTAINER_NAME mv /tmp/app.ini /data/gitea/conf/app.ini | |
docker exec -it $CONTAINER_NAME mv /tmp/repos /data/git/repositories | |
docker exec -it $CONTAINER_NAME chown -R git:git /data/git | |
docker exec -it $CONTAINER_NAME chown -R git:git /data/gitea | |
docker exec -it $CONTAINER_NAME rm -rf /tmp/* | |
docker restart $CONTAINER_NAME | |
exit 0; | |
else | |
echo "Docker container [$CONTAINER_NAME] does not exist."; | |
exit 1; | |
fi | |
else | |
echo "Backup file [$BACKUP_FILE] does not exist." | |
exit 1; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment