Skip to content

Instantly share code, notes, and snippets.

@caseyw
Created February 18, 2014 14:30
Show Gist options
  • Save caseyw/9072071 to your computer and use it in GitHub Desktop.
Save caseyw/9072071 to your computer and use it in GitHub Desktop.
Backup directory under a pretty unique name
#!/usr/bin/env bash
now=$(date +"%Y%m%d_%H%M%S")
if [[ $1 == "" ]]
then
echo "You need to specify the directory you need to backup: bkup PROJECT"
else
dir="$1"
backup="$dir"
backup+="_"
backup+="$now"
cp -rvp $dir $backup
if [ ${?} -eq 0 ]
then
echo "- Finished"
else
echo "- We had an issue"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment