改回用tar备份
This commit is contained in:
parent
487b4a7826
commit
8635c8f545
30
backup.sh
30
backup.sh
|
@ -1,17 +1,29 @@
|
|||
#!/bin/bash
|
||||
# 自动备份时使用以下命令
|
||||
# /bin/bash /sharedfolders/docker/docker-compose-projects/gitea/backup.sh
|
||||
# /bin/bash /sharedfolders/docker/gitea/backup.sh
|
||||
|
||||
backup_path="/sharedfolders/git/gitea"
|
||||
backup_time=$(date "+%Y%m%d_%H%M%S")
|
||||
backup_path="/backup"
|
||||
backup_filename=${backup_path}/$(date "+gitea-backup-%Y%m%d_%H%M%S")
|
||||
|
||||
# if sudo -n uptime 2>&1 | grep -q "load"; then
|
||||
# echo "请用root权限运行"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
cd $(dirname ${BASH_SOURCE:-$0})
|
||||
|
||||
echo "备份gitea到 ${backup_path}/gitea-backup-${backup_time}.zip ..."
|
||||
cid=$(docker-compose ps -q gitea)
|
||||
docker-compose exec -u git gitea sh -c "/app/gitea/gitea dump -V -f /data/backup/gitea-backup-${backup_time}.zip"
|
||||
if [ ${#cid} -gt 0 ]; then
|
||||
docker-compose down
|
||||
fi
|
||||
|
||||
echo "备份ssh到 ${backup_path}/gitea-ssh-${backup_time}.tgz ..."
|
||||
docker-compose exec gitea sh -c "tar -zcpf /data/backup/gitea-ssh-${backup_time}.tgz data/ssh"
|
||||
docker-compose exec gitea sh -c "chmod -R a+r mv/backup/"
|
||||
echo "备份完毕."
|
||||
# cd /
|
||||
echo "备份到 ${backup_filename}.tgz ..."
|
||||
docker-compose run --rm gitea sh -c "/app/gitea/gitea -v >/data/gitea/version.txt &&cd /data &&sqlite3 /data/gitea/gitea.db .dump >/data/gitea/gitea.sql &&tar -zcpf ${backup_filename}.tgz ssh gitea git && chown git:users /backup -R && chmod -R a+r ${backup_path}/*"
|
||||
|
||||
echo "备份完毕.请查看 ${backup_filename}.tgz"
|
||||
|
||||
echo "启动 Gitea ..."
|
||||
cd $(dirname ${BASH_SOURCE:-$0})
|
||||
docker-compose pull
|
||||
docker-compose up -d
|
Loading…
Reference in New Issue