#!/usr/bin/env bash # Use rclone to sync the last two good Wikimedia XML data dumps. set -euxo pipefail if [ -z "$1" ]; then echo "Please supply an rclone remote" exit 1 fi RCLONE_REMOTE="$1" MIRROR_URL=$(rclone config show "$RCLONE_REMOTE" | grep "url" | awk '{print $3}') NTFY_IP=$(sudo tailscale status | grep "dietpi" | awk '{print $1}') cleanup() { echo "Cleaning up" rm -fv "${HOME}/rsync-filelist-last-2-good.txt" rm -fv "${HOME}/rsync-filelist-last-2-good-en.txt" exit } trap cleanup 0 1 2 3 6 wget "${MIRROR_URL}/rsync-filelist-last-2-good.txt" \ -O "${HOME}/rsync-filelist-last-2-good.txt" grep "enwiki" "${HOME}/rsync-filelist-last-2-good.txt" | grep -v "tenwiki" | tee "${HOME}/rsync-filelist-last-2-good-en.txt" rclone sync \ --http-no-head \ -P \ --transfers 16 \ --include-from "${HOME}/rsync-filelist-last-2-good-en.txt" "${RCLONE_REMOTE}:" \ /naspool/archives/wikimedia-xmldatadumps-en curl \ -H prio:default \ -H tags:incoming_envelope \ -d "Syncing of wikimedia xml datadumps succeeded" \ "http://${NTFY_IP}:8080/wikimedia_xmldatadumps_en" exit 0