Skip to content

Instantly share code, notes, and snippets.

@travisperson
Forked from gdamjan/arch-mirror.service
Created March 29, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save travisperson/cdbd1a6161ee9403e6aca0e291af0713 to your computer and use it in GitHub Desktop.
Save travisperson/cdbd1a6161ee9403e6aca0e291af0713 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=/home/arch/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
#! /bin/bash
set -e
REPO=rsync://ftp.acc.umu.se/mirror/archlinux/
DEST=/home/arch/public_html/archlinux/
# Common rsync options
RSYNC_OPTS="-rtlH -4 --safe-links --no-motd --exclude=.*"
# Only be verbose on tty
if tty -s; then
RSYNC_OPTS="$RSYNC_OPTS -v"
fi
# first get new package files (the pool) and don't delete anything
/usr/bin/rsync $RSYNC_OPTS $REPO/pool/ $DEST/pool/
# … and only then get the database, links and the structure
/usr/bin/rsync $RSYNC_OPTS --delete-after --delay-updates $REPO $DEST \
--exclude iso/ --exclude other/ --exclude archive/ --exclude sources/
# --delete-before so that it frees disk space earlier
/usr/bin/rsync $RSYNC_OPTS --delete-before $REPO/iso/ $DEST/iso/ --exclude archboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment