-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.sh
More file actions
34 lines (27 loc) · 1.07 KB
/
sync.sh
File metadata and controls
34 lines (27 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
set -euo pipefail
# === edit these ===
SRC="/Users/gagecottom/Music/Music/Media.localized/Music"
BUCKET="s3://gages-mac-music-archive"
# storage classes: STANDARD | STANDARD_IA | INTELLIGENT_TIERING | GLACIER_IR | DEEP_ARCHIVE (for sync use STANDARD/IA/INTELLIGENT_TIERING)
STORAGE_CLASS="INTELLIGENT_TIERING"
LOG="${HOME}/music-s3-backup.log"
mkdir -p "$(dirname "$LOG")"
ts() { date '+%Y-%m-%d %H:%M:%S'; }
echo "$(ts) === music-s3-backup start ===" | tee -a "$LOG"
# Base args for reliability & cost control
ARGS=(
"--storage-class" "$STORAGE_CLASS"
"--sse" "AES256" # server-side encryption by S3 (or swap to KMS if you prefer)
"--exclude" ".DS_Store"
"--exclude" "._*"
"--exclude" ".Spotlight-*"
"--exclude" ".Trashes"
"--exclude" ".rsync-partial*"
"--exclude" "Thumbs.db"
)
echo "$(ts) MIRROR=1 (s3 will match local; deletes enabled)" | tee -a "$LOG"
aws s3 sync "$SRC" "$BUCKET" "${ARGS[@]}" --delete | tee -a "$LOG"
# quick report
echo "$(ts) Done." | tee -a "$LOG"
echo "$(ts) === music-s3-backup end ===" | tee -a "$LOG"