script: gitea fix backup

This commit is contained in:
Mathieu Maret 2021-05-30 22:42:49 +02:00
parent 09f42f5233
commit 680595f341

10
scripts/backup_gitea.sh Normal file → Executable file
View File

@ -1,16 +1,18 @@
#!/bin/bash
nb_bk=$(ls ~gitea/*dump*.zip 2>/dev/null| wc -l)
nb_bk=$(sudo ls /var/lib/gitea/ | egrep ".*dump.*.zip" |wc -l)
if [ $nb_bk != 0 ]; then
echo "EXISTING GITEA BACKUP!"
exit
fi
sudo -u gitea sh -c "cd ~gitea; gitea dump -c /etc/gitea/app.ini > /dev/null"
backup_file=$(ls ~gitea/*dump*.zip)
sudo -u gitea sh -c "cd ~gitea; gitea dump -c /etc/gitea/app.ini > /dev/null 2>&1"
backup_file=$(sudo ls /var/lib/gitea/ | egrep ".*dump.*.zip")
backup_file="/var/lib/gitea/"$backup_file
sudo mv $backup_file /tmp/
backup_file="/tmp/$(basename $backup_file)"
#echo "backup file $backup_file"
sudo chown mathieu:mathieu "${backup_file}"
sudo chmod 777 "${backup_file}"