Thread: Scripts
View Single Post
  #5  
Old 10th July 2009, 18:13
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

I use a couple real simple scripts for backup. They are on cron jobs. The one to copy the websites and database runs every night. They system backup runs once a week. Right now I move the older backups to a different folder then delete them manually but will change it to automatically delete older ones (to not fill up the disk). Note that the location of the backups is a different physical disk than the data being backed up.

backup_sites_database.sh
Quote:
#!/bin/sh
find /media/data/backup/*.tgz -mtime +14 -exec mv {} /media/data/backup/saved_backups \; > /media/data/backup/sites_database_backup_$(date +%y%m%d).txt
tar czPf /media/data/backup/mysql_backup_$(date +%y%m%d).tgz /var/lib/mysql >> /media/data/backup/sites_database_backup_$(date +%y%m%d).txt
tar czPf /media/data/backup/sites_backup_$(date +%y%m%d).tgz /var/www >> /media/data/backup/sites_database_backup_$(date +%y%m%d).txt
backup_system.sh
Quote:
#!/bin/sh
echo "Start Time" > /media/data/backup/system_backup_$(date +%y%m%d).txt
date >> /media/data/backup/system_backup_$(date +%y%m%d).txt
echo "/n Hardware Info" >> /media/data/backup/system_backup_$(date +%y%m%d).txt
hwinfo >> /media/data/backup/system_backup_$(date +%y%m%d).txt
tar czPf /media/data/backup/system_backup_$(date +%y%m%d).tgz --exclude=/proc --exclude=/dev --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/var/spool --exclude=/var/cache --exclude=/var/run --exclude=/media --exclude=/tmp --exclude=/home/servidora/Desktop --exclude=/home/servidora/.aMule/Incoming --exclude=/home/servidora/.aMule/Temp / >> /media/data/backup/system_backup_$(date +%y%m%d).txt
echo "Stop Time" >> /media/data/backup/system_backup_$(date +%y%m%d).txt
date >> /media/data/backup/system_backup_$(date +%y%m%d).txt

Note: Reading Falkos tutorial is a better way of course to back up the mysql databases. I have so little traffic that I'm not very concerned with the data changing while it's being backed up. I may implement the slave mysql server if I have that concern.
__________________
System6Hosting.com, ISPConfig 3, Debian.

Last edited by BorderAmigos; 10th July 2009 at 18:21.
Reply With Quote