From b3af48ab9580fbe1fcb1c42c51c93513186858dd Mon Sep 17 00:00:00 2001 From: chinky Date: Mon, 9 Jul 2018 09:26:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0backup.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup.sh | 15 +++++++++++++++ docker-compose.yml | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 backup.sh diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..d86d6dc --- /dev/null +++ b/backup.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# 自动备份时使用以下命令 +# /bin/bash /srv/dev-disk-by-label-hd2/docker/gitea/backup.sh + +cd $(dirname ${BASH_SOURCE:-$0}) + +cid=$(docker-compose ps -q gitea) +if [ ${#cid} -gt 0 ]; then + echo "Backuping applications ..." + docker-compose exec -T gitea /bin/bash -c "cd /app/gitea/backup; su git -c \"gitea dump\"" + exit 0 +else + echo "The container \"gitea\" not running. Please start container \"gitea\"" + exit 1 +fi \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cc8429f..e03bbc1 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ networks: external: false services: - server: + gitea: image: gitea/gitea:latest environment: - APP_NAME='通技的 gitea 服务器' @@ -27,7 +27,7 @@ services: - gitea volumes: - ./data/gitea:/data - - ./data/backup:/backup + - ./data/backup:/app/gitea/backup ports: - "3000:3000" - "22:22"