update backup.sh

This commit is contained in:
chinky 2019-06-04 17:06:25 +08:00
parent 390beb07d2
commit ecfdc98e5f

View File

@ -12,20 +12,23 @@ backup_filename=$(date "+gitea-backup-%Y%m%d_%H%M%S")
cd $(dirname ${BASH_SOURCE:-$0}) cd $(dirname ${BASH_SOURCE:-$0})
cid=$(docker-compose ps -q gitea) # cid=$(docker-compose ps -q gitea)
if [ ${#cid} -gt 0 ]; then # if [ ${#cid} -gt 0 ]; then
docker-compose up -d # docker-compose up -d
if [ ${#cid} -gt 0 ]; then # cid=$(docker-compose ps -q gitea)
exit # if [ ${#cid} -gt 0 ]; then
fi # exit
fi # fi
# fi
# cd data # cd data
echo "备份到 ${backup_path}/${backup_filename} ..." echo "备份到 ${backup_path}/${backup_filename}.zip ..."
# sudo tar -zcpf ${backup_path}/${backup_filename}.tgz gitea # 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' cid=$(docker-compose ps -q gitea)
docker cp $(docker ps -qf "name=gitea"):/data/gitea/${backup_filename}.zip ${backup_path} 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 sudo chown git:users ${backup_path} -R
docker-compose exec gitea sh -c "rm -f /data/gitea/${backup_filename}.zip"
echo "备份完毕." echo "备份完毕."
# echo "启动 Gitea ..." # echo "启动 Gitea ..."