update backup.sh

This commit is contained in:
chinky 2019-06-04 17:06:25 +08:00
parent 390beb07d2
commit ecfdc98e5f
1 changed files with 13 additions and 10 deletions

View File

@ -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 ..."