Skip to content

Instantly share code, notes, and snippets.

@jpalala
Created February 8, 2025 09:04
Show Gist options
  • Save jpalala/66f2b2900b22bcef3cc0941b2f0d59b9 to your computer and use it in GitHub Desktop.
Save jpalala/66f2b2900b22bcef3cc0941b2f0d59b9 to your computer and use it in GitHub Desktop.
rsync from a file config
#!/bin/bash
# config file looks like:
## ```
# source=$PWD
# dest=/path/to/folder
### ```
# Check if .rsync file exists
CONFIG_FILE=".rsync"
if [[ ! -f "$CONFIG_FILE" ]]; then
echo "Error: $CONFIG_FILE not found!"
exit 1
fi
# Read and evaluate the .rsync file
source <(cat "$CONFIG_FILE")
# Ensure source and dest are set
if [[ -z "$source" || -z "$dest" ]]; then
echo "Error: source or dest is not defined in $CONFIG_FILE"
exit 1
fi
# Execute rsync
rsync -av "$source/" "$dest/"
# Print completion message
echo "rsync completed from $source to $dest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment