Ubuntu webserver backup crontab…….
My god was this a pain in the ass.. It was impossible finding the correct solutions on the web to do this in Ubuntu, so for those of you who are looking to do a crontab in Ubuntu check out the following:
What im doing here is creating a crontab to backup my www root folder and my db.
To begin the process we first do the following in terminal as root or a regular user:
#>crontab -e
this will invoke nano, and you can input something similar to the following lines:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don’t have to run the crontab
# command to install the new version when you edit this file
# This file also has a username field, that none of the other crontabs doSHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=mailer@mailer.com
# m h dom mon dow user command
01 01 * * 0 /bin/tar cfP /mnt/nas/backup/www/`date +\%y-\%m-\%d`-server-name-www.tar /var/www
01 01 * * 0 /usr/bin/mysqldump –opt –all-databases > /mnt/nas/backup/mysql/`date +\%y-\%m-\%d`-server-name-mysql.sql
So basically whats happening here is we are tar-ing the www folder and sending it to the NAS drive with a timestamp. file ex will be: 09-01-01-server-name-www.tar
And its basically the same exact thing for the database backup.. Im just doing a mysqldump and the output goes to a sql file that ends up with the filename: 09-01-01-server-name-mysql.sql
Hope this helps someone..