Skip to content

Instantly share code, notes, and snippets.

@achalddave
Created April 22, 2013 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achalddave/5431736 to your computer and use it in GitHub Desktop.
Save achalddave/5431736 to your computer and use it in GitHub Desktop.
Naive Bash Backup
SRCDIR=src
DSTDIR=dst
# copy recursively (-r) updated (-u) files, preserve (-p) attributes if
# possible
$(echo "cp -R -u -p $SRCDIR/* $DSTDIR")
# hack? psh
for file in $(find $DSTDIR/*) ; do
[ ! -e "$SRCDIR/${file#*/}" ] && echo "Removing $file" && rm $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment