Project D

Automatic Backup Your Website

Tweaking, Tweaking and Tweaks MORE!

Anyway, I want to have a local server that will backup my website on my paid hosting service automatically every 1st day of every month.

So to achieve that GOAL, I setup a box, a script, ftp program and cron to do this job.

-= The Program needed =-

First try, I use the normal command line ftp programs that comes with almost all linux distributions, sadly the programs mget command cannot do directory recursive download. So Trash it!. and comes cmdftp into the picture.

Gentoo User

emerge cmdftp

-= Bash script =-

Easy, simple and short!. just copy paste and edit this script :

#!/bin/bash
## If you dont have cmdftp program installed do emerge cmdftp

SITE=YOURSITE-NAME
LOCALPATH=YOUR-LOCAL-PATH
BACKUPDIR=/$LOCALPATH/$SITE.backup.$(date +%Y%m%d)

mkdir $BACKUPDIR
cd $BACKUPDIR

/usr/bin/cmdftp ftp.$SITE << **
cd /www
d * .
bye
**
exit 0

Don’t forget to make it executable by issuing

chmod +x FILENAME

-= Crontab for automation process =-

Sometimes you’ll need root access to add crontab job, it really depends on how you / your admin sets the box.

Anyway, you will need to put this line into a new file, you can save the file into anything.

* * 1 * * /usr/local/bin/masindotape.backup.sh > /dev/null

Then as root/user that have sufficient permission to run crontab do :

crontab -u YOUR-USERNAME FILENAME

-= END =-

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • blinkbits
  • eKudos
  • Live
  • Share/Save/Bookmark

RSS Fresh Ebuild