<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>How about something like this......<br><br>#!/bin/bash<br><br># This script makes a backup of the files on the primary server directory.<br><br># Change the values of the variables to make the script work:<br>BACKUPDIR=/data/<br>BACKUPFILES=*.cdf<br>GZTARFILE=/var/tmp/data_$(date +%F).tar.gz<br>SERVER=mcastasp1<br>REMOTEDIR=/home/admin/DATA_BKP<br>LOGFILE=/home/admin/DATA_BKP/backup.log<br>CLEANUP=/home/admin/DATA_BKP<br><br>cd $BACKUPDIR<br><br># This creates the archive<br>tar zcf $GZTARFILE $BACKUPFILES > /dev/null 2>&1<br><br># Create Remote backup Directory<br>ssh $SERVER 'mkdir -p /home/admin/DATA_BKP'<br><br># Copy the file to another host - we have ssh keys for making this work without intervention.<br>scp $GZTARFILE $SERVER:$REMOTEDIR > /dev/null 2>&1<br><br>#
 Redirect errors because this generates some if the archive<br># does not exist.<br>rm $GZTARFILE 2> /dev/null<br><br># Create a timestamp in a logfile.<br>date >> $LOGFILE<br>echo backup succeeded >> $LOGFILE<br><br># Clean up remote server and leave 7 days of backup files<br>ssh $SERVER 'find /home/admin/DATA_BKP/ -follow -name 'data_*' -ctime +7 -exec rm {} \;'<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Alan Hoffmeister <alangtk@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> centos@centos.org<br><b><span style="font-weight: bold;">Sent:</span></b> Mon, January 25, 2010 1:48:19 PM<br><b><span style="font-weight: bold;">Subject:</span></b> [CentOS] Bash script for backup<br></font><br>Hello
 guyz!<br><br>I'm new here, and this is my very first truble...<br><br>I need a script that will backup & compress the folder /media/system in <br>the folder /media/backups<br><br>But that's not the problem, I need that only the last 7 backups (last 7 <br>days, yeah I know, cronjob...) will stay in that folder...<br><br>The script need:<br>1 - Compress folder /media/system<br>2 - Store in /media/backups<br>3 - Name the compressed backup like day_month_year.tar.gzip<br>4 - Check the other backups and delete backups older than 7 days..<br><br>Can some one help me?<br><br>Tanks!<br>_______________________________________________<br>CentOS mailing list<br><a ymailto="mailto:CentOS@centos.org" href="mailto:CentOS@centos.org">CentOS@centos.org</a><br><a href="http://lists.centos.org/mailman/listinfo/centos" target="_blank">http://lists.centos.org/mailman/listinfo/centos</a><br></div></div>
<!-- cg4.c202.mail.ac4.yahoo.com compressed/chunked Fri Jan 22 12:03:55 PST 2010 -->
</div></body></html>