Hey, I'm looking for some help on my little backup script for my server. I'm not a real savvy scripter so please bare with me :) I googled around awhile back and put together a bu script that has served my purpose well until now. It's just a few lines as you will see and I use it with cron to make a cdrw every morning at 3am.
Now the info on my server is starting to outgrow just on cdrw (jpgs and such) so I would like to know how I can modify my script to be able to exclude either certain files or directories. I imagine that sed would be involved, but I don't completely understand that tool so I'm hoping that someone might be able to give me some pointers and maybe even explain how the code will work in that setting. Well, here's what I've got now:
Michael,
attached you'll find the one i've been using and it works flawlessly. I can't remember his name, but it was a gentleman here on the expert list that sent me a copy of his and I used his as a guide to cook this one up.
enjoy...
-- Mark ----------------------------------------------------------- Paid for by Penguins against modern appliances(R) Linux User Since 1996 Powered by Mandrake Linux 8.2 & 9.1 ICQ# 27816299
#!/bin/sh #MAILTO:mdw1982 # ########################## # variables for the program: # ########################## TAPE=/dev/st0; HOME_FILES=/home; DOCUMENTS=/mnt/arc_2/Documents; WWW=/var/www; MAIL=/var/spool/mail; DATABASE=/var/lib/mysql; MP3=/mnt/mp3; LOG_PATH=/home/mdw1982/; LOG_DIR=backup_log; DATE=$( date +%m-%d-%Y );
# ########################## # functions for program : # ########################## message(){ echo ".........This is the Tape backup program.........."; echo " ------------------------------- "; echo ""; echo "I've successfully completed the nightly backup of the system"; echo "for $DATE"; echo ""; echo "The Log file containing the backup's contents has been written"; echo "to $LOG_PATH."; echo "............. END OF TRANSMISSION ................"; } # does the directory to receive the backup logs exist? # if not then we're going to create it... checkLog(){ for i in $( ls -d /home/mdw1982/* ); do ITEM=$i if [ $ITEM = $LOG_DIR ] then FOUND=true else FOUND=false fi done } # ########################## # main program : # ########################## # putting all the goodies to the tape find /bin /boot /etc /home /root /var /mnt/arc_2/Documents /var/www -print | grep -iv "\./var/ftp" | sort | cpio -oaBc -O /dev/tape # writing out the logfile to disk cpio -iBct -I /dev/tape > /home/mdw1982/backup_log/$( date +%m-%d-%Y )_bkup.indx # compressing the logfile gzip -1 /home/mdw1982/backup_log/$( date +%m-%d-%Y )_bkup.indx # outputing message to email message; # exiting the program exit;
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com