gitea/restore.sh

48 lines
890 B
Bash
Raw Normal View History

2019-06-04 16:20:18 +08:00
#!/bin/bash
backup_path="/sharedfolders/git/gitea"
cd $(dirname ${BASH_SOURCE:-$0})
cid=$(docker-compose ps -q gitea)
if [ ${#cid} -gt 0 ]; then
docker-compose down
fi
# 恢复备份
PS3="请选择恢复的备份: "
menu=$(ls -1 ${backup_path} | grep "gitea-backup")
select dump_filename in ${menu} "退出"
do
if [ -n "${dump_filename}" ]; then
case "${dump_filename}" in
"退出")
exit 1
;;
*)
break
;;
esac
fi
done
read -n1 -p "恢复备份 : ${dump_filename} (N/y)? : " answer
case $answer in
Y|y)
echo
echo "恢复备份 \"${dump_filename}\" 中 ..."
mkdir -p ./data
cd data
sudo mv gitea $(date "+gitea%Y%m%d_%H%M%S")
sudo tar -zxf ${backup_path}/${dump_filename}
echo "恢复完毕."
echo "启动 Gitea ..."
docker-compose up -d
;;
*)
echo
exit 1
;;
esac