Skip to content

Instantly share code, notes, and snippets.

@timtomch
Last active August 29, 2015 14:09
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 timtomch/f2339509c130e5663349 to your computer and use it in GitHub Desktop.
Save timtomch/f2339509c130e5663349 to your computer and use it in GitHub Desktop.
Backup home directory on web server (cron task)
#!/bin/bash
tar czf path/to/backup/dir/webbackup_`date +%Y_%m_%d`.tgz -X backup-exclude.txt -C path/to/public_html public_html/
@timtomch
Copy link
Author

backup-exclude.txt contains a list of files/directories/patterns to be excluded, one by line:

cgi-bin/
temp/
myfile.txt
*.dat

@timtomch
Copy link
Author

The path to public_html in the -C option must not contain public_html itself, obviously. This can be omitted, in which case the tar will contain the entire path to public_html. With the -C option, tar first changes to the directory just below public_html, then is executed on public_html.

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