Surpreendentemente, isso pode ser feito com rsync(1)
sozinho, sem acesso ao servidor remoto.
Presumindo bash(1)
e GNU date(1)
:
#! /usr/bin/env bash
src=rsync://example.com/archives/
dst=/path/to/mirrors
cutoff=$( date -d '7 days ago' +%s )
rsync -na --no-motd --out-format='%M %f' "$src" "$dst" | \
while IFS= read -r line; do
d=${line%% *}
fn=${line#* }
fdate=$( date -d "${d/-/ }" +%s ) || continue
if [ $fdate -ge $cutoff ]; then printf '%s#! /usr/bin/env bash
src=rsync://example.com/archives/
dst=/path/to/mirrors
cutoff=$( date -d '7 days ago' +%s )
rsync -na --no-motd --out-format='%M %f' "$src" "$dst" | \
while IFS= read -r line; do
d=${line%% *}
fn=${line#* }
fdate=$( date -d "${d/-/ }" +%s ) || continue
if [ $fdate -ge $cutoff ]; then printf '%s%pre%' "$fn"; fi
done | \
rsync -a --files-from=- -0 "$src" "$dst"
' "$fn"; fi
done | \
rsync -a --files-from=- -0 "$src" "$dst"