Archive for the 'Shell Scripting' Category

Backup Script

November 25, 2007

#!/bin/sh
# Backup all files under home directory to a single # floppy
# Display message with option to cancel
dialog –title “Backup” –msgbox “Time for backup \ of home directory. \
Insert formatted 3-1/2\” floppy and press \ to start backup or \
to cancel.” 10 50
# Return status of non-zero indicates cancel
if [ “$?” != “0″ ]
then
dialog –title “Backup” –msgbox “Backup was \ canceled at your
request.” 10 50
else
dialog –title “Backup” –infobox “Backup in \ process…” 10 50
cd ~
# Backup using tar; redirect any errors to a
# temporary file
# For multi-disk support, you can use the
# -M option to tar
tar -czf /dev/fd1 . >|/tmp/ERRORS$$ 2>&1
# zero status indicates backup was successful
if [ “$?” = “0″ ]
then
dialog –title “Backup” –msgbox “Backup \
completed successfully.” 10 50
# Mark script with current date and time
touch ~/.backup
else
# Backup failed, display error log
dialog –title “Backup” –msgbox “Backup failed \ — Press

to see error log.” 10 50
dialog –title “Error Log” –textbox /tmp/ERRORS$$ 22 72
fi
fi
rm -f /tmp/ERRORS$$
clear
To run this automatically, I put these lines in my .profile file to call the backup script on login if more than 3 days has elapsed since the last backup was made:

# do a backup if enough time has elapsed
find ~/.backup -mtime +3 -exec ~/.backup \;

Script para Descargar los 6 discos Centos 5

November 25, 2007

#!/bin/bash

#Author: Jamil De Jesus Enríquez Deceano
#Date: Saturday 24 November 2007
#License: GPL

cd /home/kukako
for ((i=1; i< =6; i++))
do
echo “BEGIN DOWNLOAD DISCO $i CENTOS 5″
echo
wget -d -r -c http://altruistic.lbl.gov/mirrors/centos/5.0/isos/i386/CentOS-5.0-i386-bin-”$i”of6.iso
done
echo “Finish download Centos 5 completed !!!”
exit 0