Created
June 12, 2023 20:53
-
-
Save dgant/495157f5813c72c9fa2f5af84c76112c to your computer and use it in GitHub Desktop.
Script to create a datestamped backup of your project
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 | |
src_dir="/c/MyProject" | |
base_tgt_dir="/d/MyProjectBackups" | |
current_date=$(date +"%Y-%m-%d") | |
tgt_dir="${base_tgt_dir}/${current_date}" | |
# If the target directory already exists, delete it first | |
if [ -d "$tgt_dir" ]; then | |
rm -rf "$tgt_dir" | |
fi | |
# Recursively copy the source directory to the target directory with the current date | |
echo "Backing up from '$src_dir' to '$tgt_dir'" | |
cp -r "$src_dir" "$tgt_dir" | |
echo "The directory '$src_dir' has been copied to '$tgt_dir'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment