Backup & Archive Patterns
find + tar — archive recently modified files
# Archive .adoc files modified in the last 7 days
find ~/atelier/_bibliotheca/domus-captures/docs -name "*.adoc" -type f -mtime -7 -print0 | \
tar --null -czf /tmp/recent-adoc-backup.tar.gz --files-from=-
# Verify contents
tar tzf /tmp/recent-adoc-backup.tar.gz | head -10
find + cpio — create cpio archive
# cpio reads file list from stdin — find provides it
find ~/atelier/_bibliotheca/domus-captures/docs/modules/ROOT/partials -name "*.adoc" -type f | \
cpio -o > /tmp/partials-backup.cpio
# List contents
cpio -t < /tmp/partials-backup.cpio | head -10
find + rsync — sync only specific file types
mkdir -p /tmp/rsync-staging
# Use find to build include list, rsync to transfer
rsync -av --files-from=<(
find ~/atelier/_bibliotheca/domus-captures/docs -name "*.adoc" -type f \
-printf '%P\n'
) ~/atelier/_bibliotheca/domus-captures/docs/ /tmp/rsync-staging/
ls /tmp/rsync-staging/ | head -10
Archive files by date range — between two dates
# Create reference timestamps
touch -t 202604010000 /tmp/ref-start
touch -t 202604110000 /tmp/ref-end
# Find files modified between those dates
find ~/atelier/_bibliotheca/domus-captures/docs -name "*.adoc" -type f \
-newer /tmp/ref-start ! -newer /tmp/ref-end -print | head -20
# Archive the range
find ~/atelier/_bibliotheca/domus-captures/docs -name "*.adoc" -type f \
-newer /tmp/ref-start ! -newer /tmp/ref-end -print0 | \
tar --null -czf /tmp/date-range-backup.tar.gz --files-from=-
rm /tmp/ref-start /tmp/ref-end
Backup configs before changes — cp to .bak
# Backup all .conf files in /etc (dry run — just list)
find /etc -maxdepth 2 -name "*.conf" -type f -print 2>/dev/null | head -10
# Create .bak copies (requires sudo for /etc)
# sudo find /etc -maxdepth 2 -name "*.conf" -type f \
# -exec cp -v {} {}.bak \;
Find and compress old logs
# Find uncompressed logs older than 30 days
find /var/log -name "*.log" -type f -mtime +30 ! -name "*.gz" -print 2>/dev/null | head -10
# Compress them in place (dry run — just list sizes)
find /var/log -name "*.log" -type f -mtime +30 ! -name "*.gz" \
-exec ls -lh {} + 2>/dev/null
Create manifest of files — find -printf for metadata
# Full metadata manifest: permissions, size, mod time, path
find ~/atelier/_bibliotheca/domus-captures/docs/modules/ROOT/pages -name "*.adoc" -type f \
-printf '%M %s %T+ %p\n' | sort -k3 -r | head -20
# Tab-delimited for machine parsing
find ~/atelier/_bibliotheca/domus-captures/docs/modules/ROOT/pages -name "*.adoc" -type f \
-printf '%s\t%T@\t%p\n' > /tmp/file-manifest.tsv
wc -l /tmp/file-manifest.tsv
Archive and remove in one pass — move to archive directory
mkdir -p /tmp/archived-logs
# Move old log files to archive (safer than delete)
cat <<'SCRIPT' > /tmp/archive-and-remove.sh
#!/usr/bin/env bash
set -euo pipefail
ARCHIVE_DIR="/tmp/archived-logs"
find /tmp -maxdepth 1 -name "*.log" -type f -mtime +7 \
-exec mv -v {} "$ARCHIVE_DIR/" \;
echo "Archived $(ls "$ARCHIVE_DIR" | wc -l) files"
SCRIPT
bash /tmp/archive-and-remove.sh