aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdevuan_package_mirror_sync.sh97
1 files changed, 97 insertions, 0 deletions
diff --git a/devuan_package_mirror_sync.sh b/devuan_package_mirror_sync.sh
new file mode 100755
index 0000000..23381a7
--- /dev/null
+++ b/devuan_package_mirror_sync.sh
@@ -0,0 +1,97 @@
1#!/bin/bash
2
3# I've not found a way to do this in one rsync call, so here's two.
4#
5# The first one adds any new actual package files, including source and such.
6# It excludes the metadata files.
7#
8# The second one doesn't exclude anything, which will pick up the
9# metadata files exclruded the first time, then delete anything that should
10# be deleted.
11#
12# In this way the amount of time where your mirror isn't fully valid is minimised.
13
14# NOTE - You will need to customize this script. MIRROR_PATH is the path
15# to your mirror, BEHAVE is limits on the rsync commands, OPTIONS
16# includes "--chown mirrors:www-data" change that to the user and group
17# you want your files to be. --exclude "/devuan-cd/" may need to be
18# changed or removed if you run a file / ISO mirror.
19
20# Stop on errors, and don't expand *
21set -ef
22
23MIRROR_PATH="/srv/mirrors/files.devuan.org"
24BEHAVE="ionice -c3 nice -n 19"
25
26# Bits from the rsync 3.2.7 man page.
27# For remote transfers, a modern rsync uses ssh for its communications,
28# SORTED TRANSFER ORDER
29# Rsync always sorts the specified filenames into its internal transfer list. This handles the merging together of the contents of identically named directories,
30# makes it easy to remove duplicate filenames. It can, however, confuse someone when the files are transferred in a different order than what was given on the command-line.
31# If you need a particular file to be transferred prior to another, either separate the files into different rsync calls, or consider using --delay-updates
32# (which doesn't affect the sorted transfer order, but does make the final file-updating phase happen much more rapidly).
33# NOTE - Seems we have to use the double rsync method, coz symlinks update in the wrong order, no matter what we do.
34
35OPTIONS="--delay-updates -rlptSzhhv --no-motd --chown mirrors:www-data -M--open-noatime"
36# --verbose, -v increase verbosity
37# --no-motd suppress daemon-mode MOTD
38# --archive, -a archive mode is -rlptgoD (no -A,-X,-U,-N,-H)
39# --recursive, -r recurse into directories
40# NOTE - --inc-recursive, --i-r is the default, but --delay-updates disables it.
41# --mkpath create destination's missing path components
42# "just as if mkdir -p $DEST_PATH had been run on the receiving side."
43# SIGH - other complications.
44# --links, -l copy symlinks as symlinks
45# NOTE - symlink handling is complex.
46# --hard-links, -H preserve hard links
47# --perms, -p preserve permissions
48# --acls, -A preserve ACLs (implies --perms)
49# --xattrs, -X preserve extended attributes
50# --owner, -o preserve owner (super-user only)
51# --group, -g preserve group
52# --devices preserve device files (super-user only)
53# --specials preserve special files
54# -D same as --devices --specials
55# --times, -t preserve modification times
56# --atimes, -U preserve access (use) times
57# --open-noatime avoid changing the atime on opened files
58# Not in 3.1.2 version.
59# --crtimes, -N preserve create times (newness)
60# Not in 3.1.2 version.
61# --sparse, -S turn sequences of nulls into sparse blocks
62# --delete-delay find deletions during, delete after
63# --delay-updates put all updated files into place at end
64# "See also the "atomic-rsync" python script in the "support" subdir for an update algorithm that is even more atomic (it uses --link-dest and a parallel hierarchy of files)."
65# NOTE - worth a look later.
66# --chown=USER:GROUP simple username/groupname mapping
67# --compress, -z compress file data during the transfer
68# --exclude=PATTERN exclude files matching PATTERN
69# --copy-as=USER[:GROUP] specify user & optional group for the copy
70# --human-readable, -h output numbers in a human-readable format
71# --remote-option=OPT, -M send OPTION to the remote side only
72
73# Exclude metadata files.
74EXCLUDES="--exclude Packages* \
75 --exclude Sources* \
76 --exclude Release* \
77 --exclude InRelease \
78 --exclude Contents-* \
79 --exclude Translation-* \
80 --exclude ls-lR* \
81 --exclude .~tmp~"
82
83mkdir -p ${MIRROR_PATH}
84# The --exclude "/devuan-cd/" is so we don't wipe out the ISO mirror.
85time $BEHAVE flock -n ${MIRROR_PATH}/devuan rsync ${OPTIONS} vesta@pkgmaster.devuan.org:~/devuan/ ${MIRROR_PATH} --exclude "/devuan-cd/" $EXCLUDES \
86 | grep -Ev '/$|\.svg|\.txt$|\.txt.old$|versionlog\.state|log/sources|aintainers$' | head -n -1 | tail -n +2
87echo ""
88time $BEHAVE flock -n ${MIRROR_PATH}/devuan rsync ${OPTIONS} --delete-delay vesta@pkgmaster.devuan.org:~/devuan/ ${MIRROR_PATH} --exclude "/devuan-cd/" \
89 | grep -Ev '/$|\.svg|\.txt$|\.txt.old$|versionlog\.state|log/sources|aintainers$' | head -n -1 | tail -n +2
90
91
92# These helped -
93# https://git.devuan.org/devuan/amprolla3/src/branch/test/deployment/orchestrate.sh#L84
94# https://chrisgilmerproj.github.io/debian/mirror/rsync/2013/08/29/mirror-debian.html
95# https://pkgmaster.devuan.org/devuan_mirror_walkthrough.txt
96
97# Investigated rsync batch mode, seems crap for our use.