Skip to content

Instantly share code, notes, and snippets.

@brunos3d
Created January 19, 2023 20:50
Show Gist options
  • Save brunos3d/9f93524b4a88d04c3ea8149293c60b21 to your computer and use it in GitHub Desktop.
Save brunos3d/9f93524b4a88d04c3ea8149293c60b21 to your computer and use it in GitHub Desktop.
A shell script that make a backup for your env files keeping the same directory structure
#!/bin/bash
input_path=$1
output_path=$2
# Find all .env files in the input path
for file in $(find "$input_path" -name "*.env"); do
# Get the file path relative to the input path
relative_path="${file#$input_path/}"
# Create the same directory structure in the output path
mkdir -p "$output_path/$(dirname "$relative_path")"
# Copy the file to the output path
cp "$file" "$output_path/$relative_path"
done
@brunos3d
Copy link
Author

just run chmod +x ./copy-envs.sh then ./copy-envs.sh /path/to/envs /output/path/to/copies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment