Very Basic Site Backup Bash Script

I wrote this to simply backup a site. Its quick and dirty, but gets the job done. Save this file as “savesite” or whatever you want and “chmod +x {filename}”. If its hushed-up a bit it can be set as a cronjob. I’ll mess around with this when its not 1:30am on a thursday.

MAKE SURE YOU HAVE A DIRECTORY “~/backups” OR CHANGE THE “backupdir” variable!

Usage:
./savesite www.example.com

#!/bin/bash
stamp=$(date +%m-%d-%Y)
domain=$1
backupdir=~/backups/$domain-$stamp
tmpdir=/tmp/sitebackup_$stamp/
mkdir $tmpdir
cd $tmpdir
wget --mirror --domains=$domain $domain
tar -czf $backupdir.tar.gz $tmpdir
rm -r $tmpdir



Comments

No comments yet.

Add Yours

  • Author Avatar

    YOU


Comment Arrow



About Author

Rob Hurring

Ruby, Rails, PHP, bash... oh my!