config/scripts/backup_gitea.sh

22 lines
599 B
Bash
Raw Normal View History

2020-11-11 21:54:24 +01:00
#!/bin/bash
2022-09-22 15:50:12 +02:00
nb_bk=$(sudo ls /var/lib/gitea/ | grep -E ".*dump.*.zip" |wc -l)
2020-11-11 21:54:24 +01:00
if [ $nb_bk != 0 ]; then
echo "EXISTING GITEA BACKUP!"
exit
fi
2021-05-30 22:42:49 +02:00
sudo -u gitea sh -c "cd ~gitea; gitea dump -c /etc/gitea/app.ini > /dev/null 2>&1"
2020-11-11 21:54:24 +01:00
2022-09-22 15:50:12 +02:00
backup_file=$(sudo ls /var/lib/gitea/ | grep -E ".*dump.*.zip")
2021-05-30 22:42:49 +02:00
backup_file="/var/lib/gitea/"$backup_file
sudo mv $backup_file /tmp/
backup_file="/tmp/$(basename $backup_file)"
2020-11-11 21:54:24 +01:00
#echo "backup file $backup_file"
sudo chown mathieu:mathieu "${backup_file}"
sudo chmod 777 "${backup_file}"
scp "${backup_file}" mathieu@bk.mathux.org:/srv/share/backup/
sudo rm $backup_file