Skip to content

Instantly share code, notes, and snippets.

@codeachange
Created August 15, 2013 07:38
Show Gist options
  • Save codeachange/6238964 to your computer and use it in GitHub Desktop.
Save codeachange/6238964 to your computer and use it in GitHub Desktop.
shell script to backup a directory
#!/bin/bash
# This file must be put in the same directory of TargetDir
# Because using relative path to avoid tar warning:
# tar: Removing leading `/' from member names
TargetDir="html"
DestDir="/var/www/backup/dir"
NOW="$(date +"%Y-%m-%d")"
tar -czf "$DestDir/html.$NOW.tar.gz" "$TargetDir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment