Skip to content

Instantly share code, notes, and snippets.

@gdamjan
Last active May 12, 2024 15:15
Show Gist options
  • Save gdamjan/cc3a65cf9afa5fd7645c to your computer and use it in GitHub Desktop.
Save gdamjan/cc3a65cf9afa5fd7645c to your computer and use it in GitHub Desktop.
script to rsync from an arch mirror
[Unit]
Description=Mirror arch linux
[Service]
Type=oneshot
ExecStart=/usr/local/bin/sync_arch_mirror.sh
User=arch
IPAccounting=yes
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectSystem=strict
ProtectControlGroups=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
MemoryDenyWriteExecute=yes
RestrictRealtime=yes
RestrictNamespaces=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
SystemCallArchitectures=native
LockPersonality=yes
[Unit]
Description=Mirror arch almost every two hours
[Timer]
OnBootSec=15min
OnUnitActiveSec=2h10m
AccuracySec=10min
[Install]
WantedBy=timers.target
pool/packages
core
core-testing
extra
extra-testing
multilib
multilib-testing
lastsync
lastupdate
#! /bin/bash
set -euo pipefail
if [ "$EUID" -eq 0 ]
then echo "Don't run as root!"
exit 1
fi
REPO=rsync://ftp.acc.umu.se/mirror/archlinux
DEST=/srv/arch_mirror/archlinux
RSYNC_FILE_LIST=/srv/arch_mirror/archlinux-rsync-file-list.txt
mkdir -p $DEST
# Common rsync options
: "${LAZY:="--delete-delay --delay-updates"}"
RSYNC_OPTS="-rltH -4 --safe-links --no-motd $LAZY"
# Only be verbose on tty
if tty -s; then
RSYNC_OPTS="$RSYNC_OPTS -v"
fi
/usr/bin/rsync $RSYNC_OPTS --files-from=$RSYNC_FILE_LIST $REPO/ $DEST/
@gdamjan
Copy link
Author

gdamjan commented Oct 24, 2017

Oct 24 14:10:55 mk.arch.mirror systemd[1]: Starting Mirror arch linux...
Oct 24 14:11:27 mk.arch.mirror systemd[1]: Started Mirror arch linux.
Oct 24 14:11:27 mk.arch.mirror systemd[1]: arch-mirror.service: Received 149.1M IP traffic, sent 1.5M IP traffic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment