From ecfdc98e5f81792f92b58abd6542f6f930d27e46 Mon Sep 17 00:00:00 2001 From: chinky Date: Tue, 4 Jun 2019 17:06:25 +0800 Subject: [PATCH] update backup.sh --- backup.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/backup.sh b/backup.sh index 26d1ca0..98d08db 100644 --- a/backup.sh +++ b/backup.sh @@ -12,20 +12,23 @@ backup_filename=$(date "+gitea-backup-%Y%m%d_%H%M%S") cd $(dirname ${BASH_SOURCE:-$0}) -cid=$(docker-compose ps -q gitea) -if [ ${#cid} -gt 0 ]; then - docker-compose up -d - if [ ${#cid} -gt 0 ]; then - exit - fi -fi +# cid=$(docker-compose ps -q gitea) +# if [ ${#cid} -gt 0 ]; then +# docker-compose up -d +# cid=$(docker-compose ps -q gitea) +# if [ ${#cid} -gt 0 ]; then +# exit +# fi +# fi # cd data -echo "备份到 ${backup_path}/${backup_filename} ..." +echo "备份到 ${backup_path}/${backup_filename}.zip ..." # sudo tar -zcpf ${backup_path}/${backup_filename}.tgz gitea -docker-compose exec -u git gitea sh -c '/app/gitea/gitea dump -f /data/gitea/${backup_filename}.zip' -docker cp $(docker ps -qf "name=gitea"):/data/gitea/${backup_filename}.zip ${backup_path} +cid=$(docker-compose ps -q gitea) +docker-compose exec -u git gitea sh -c "/app/gitea/gitea dump -V -f /data/gitea/${backup_filename}.zip" +docker cp ${cid}:/data/gitea/${backup_filename}.zip ${backup_path} sudo chown git:users ${backup_path} -R +docker-compose exec gitea sh -c "rm -f /data/gitea/${backup_filename}.zip" echo "备份完毕." # echo "启动 Gitea ..."