gitea/backup.sh

18 lines
702 B
Bash

#!/bin/bash
# 自动备份时使用以下命令
# /bin/bash /sharedfolders/docker/docker-compose-projects/gitea/backup.sh
backup_path="/sharedfolders/git/gitea"
backup_time=$(date "+%Y%m%d_%H%M%S")
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"
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 "备份完毕."