Created
February 8, 2025 09:04
-
-
Save jpalala/66f2b2900b22bcef3cc0941b2f0d59b9 to your computer and use it in GitHub Desktop.
rsync from a file config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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