#!/usr/bin/env bash export PS4='+$0:$LINENO ' set -o errtrace set -o pipefail set -o xtrace gitea_bin=/usr/local/bin/gitea today="$(date -I)" # yyyy-mm-dd backup_dir="/tmp/gitea-backup-$today" storage="yandex:/backups" # rclone config, ~/.config/rclone/rclone.conf stuff_to_copy=( /etc/systemd/system/gitea.service /etc/nginx/sites-available/gitea.conf ) mkdir -p "$backup_dir" for item in "${stuff_to_copy[@]}"; do cp -r "$item" "$backup_dir" done su -c "$gitea_bin dump -c /etc/gitea/app.ini -f $backup_dir/gitea_dump.zip" - git tar -czvf "$backup_dir.tar.gz" "$backup_dir" && rm -rvf "$backup_dir" rclone copy "$backup_dir.tar.gz" "$storage/" --progress && rm -v "$backup_dir.tar.gz" exit "$?"