Dialy Backup Task

I would like to share some experience on daily backup task even though I'm not a Linux expert.

Noticed below user group created.
someonex:500:
apache:x:48:
mysql:x:27:
webmaster:x:501:
fred:x:502:

Suggest to create a backup group with a dedicated user for backing up db & web src.
 
A sample db backup script is available at /home/fred/backup_db.sh
The last command (I coded all tables) in script is commended out for Fred to inform all of us which table should be backup.
=============================================
aDate=`date +%Y%m%d`
filename="bkup""$aDate"
echo "Creating daily backup <"$aDate"/"$filename">"
#mysqldump –add-drop-table –allow-keywords -q -a -c -u username -ppassword –all-databases > $filename.sql =============================================

A sample cron job is setup to run the backup scripts. (Please note that the cron job is exec under the user home, so the cron jobs has to be set under the new user instead of Fred/root)
e.g. every day 18:30
=============================================
[fred@panda ~]$ crontab -l
30     18     *     *     *         ./backup_db.sh > backup.log
=============================================

Belows stated fyr to edit the cron job. 
crontab -e     Edit your crontab file, or create one if it doesn't already exist.
crontab -l      Display your crontab file.
crontab -r      Remove your crontab file.
crontab -v      Display the last time you edited your crontab file. (This option is only available on a few systems.)

If www scripts are expected to create daily backup, similar scripts should be setup.
** The scripts should be coded in a better manner to spool a log instead of redirecting from cron job 😀

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.