Compare commits
8
Commits
fdb9c3da09
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f0386f488 | ||
|
|
5f64cdce3f | ||
|
|
f93da30d75 | ||
|
|
f66aea6054 | ||
|
|
6b0776003d | ||
|
|
5707598046 | ||
|
|
72ac6e3ce6 | ||
|
|
4f3ca893d5 |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
*.local
|
||||
.DS_Store
|
||||
@@ -1,14 +1,14 @@
|
||||
# Remote rsync source. Example: backup@example.com:/srv/data/project/
|
||||
RSYNC_SOURCE="boogie@eukelade.uberspace.de:/home/boogie/nextcloud_data/root/files/Obsidian"
|
||||
# SSH key file used by rsync/ssh
|
||||
SSH_KEY_FILE="/mnt/bfds-nix/rob/backup/Obsidian-daily-git/.ssh/obsidian-backup"
|
||||
|
||||
|
||||
# Local sync destination (must be a directory inside GIT_REPO_DIR)
|
||||
RSYNC_TARGET_DIR="/Users/rob/code/obsidian-backup/tests"
|
||||
|
||||
# Local monorepo path
|
||||
GIT_REPO_DIR="/Users/rob/code/obsidian-backup/tests"
|
||||
RSYNC_TARGET_DIR="/mnt/bfds-nix/rob/backup/Obsidian-daily-git/"
|
||||
|
||||
# Prefix for commit message (timestamp is appended automatically)
|
||||
COMMIT_MESSAGE_PREFIX="backup: rsync sync"
|
||||
|
||||
# Optional: custom SSH command for rsync (leave empty if not needed)
|
||||
# RSYNC_RSH="ssh -i /path/to/key -o StrictHostKeyChecking=yes"
|
||||
# RSYNC_RSH="ssh -i /path/to/key -o StrictHostKeyChecking=yes"
|
||||
@@ -8,5 +8,11 @@ RSYNC_TARGET_DIR="/path/to/backup-repo"
|
||||
# Prefix for commit message (timestamp is appended automatically)
|
||||
COMMIT_MESSAGE_PREFIX="backup: rsync sync"
|
||||
|
||||
# Optional: custom SSH command for rsync (leave empty if not needed)
|
||||
# SSH key file used by rsync/ssh
|
||||
SSH_KEY_FILE="/root/.ssh/backup_rsync"
|
||||
|
||||
# Optional extra SSH options
|
||||
# SSH_OPTIONS="-o IdentitiesOnly=yes -o StrictHostKeyChecking=yes"
|
||||
|
||||
# Optional full custom SSH command for rsync (overrides SSH_KEY_FILE/SSH_OPTIONS)
|
||||
# RSYNC_RSH="ssh -i /path/to/key -o StrictHostKeyChecking=yes"
|
||||
@@ -37,6 +37,16 @@ for var in "${required_vars[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "${RSYNC_RSH:-}" && -z "${SSH_KEY_FILE:-}" ]]; then
|
||||
echo "Missing SSH config: set SSH_KEY_FILE or RSYNC_RSH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n "${SSH_KEY_FILE:-}" && ! -r "$SSH_KEY_FILE" ]]; then
|
||||
echo "SSH key file not readable: $SSH_KEY_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$RSYNC_TARGET_DIR"
|
||||
|
||||
repo_abs="$(cd "$RSYNC_TARGET_DIR" && pwd)"
|
||||
@@ -52,7 +62,14 @@ git_target() {
|
||||
}
|
||||
|
||||
if [[ -n "${RSYNC_RSH:-}" ]]; then
|
||||
rsync -az --delete -e "$RSYNC_RSH" "$RSYNC_SOURCE" "$repo_abs/"
|
||||
rsync_rsh="$RSYNC_RSH"
|
||||
else
|
||||
ssh_options="${SSH_OPTIONS:--o IdentitiesOnly=yes -o StrictHostKeyChecking=yes}"
|
||||
rsync_rsh="ssh -i $SSH_KEY_FILE $ssh_options"
|
||||
fi
|
||||
|
||||
if [[ -n "${rsync_rsh:-}" ]]; then
|
||||
rsync -az --delete -e "$rsync_rsh" "$RSYNC_SOURCE" "$repo_abs/"
|
||||
else
|
||||
rsync -az --delete "$RSYNC_SOURCE" "$repo_abs/"
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user