[olug] Script help

Craig Wolf cjwolf at mpsomaha.org
Sun Dec 28 23:22:04 UTC 2008


I am trying to learn how to write scripts.  My first one is a simple backup script BUT I am having problems with assigning  data to a variable: DIRNAME.  
See following:

# 12/28/2008
DIRNAME = 'backup_'$date +%Y-%m%d

# Create directory on external drive
echo "md /usr/backups-data/$DIRNAME"

# Backup home directory to external drive
echo "cp -Rp /home/* /usr/backups-data/$DIRNAME/home/"

# Backup the config files for the system
echo "cp -Rp /etc/samba/* /usr/backups-data/$DIRNAME/samba/"
echo "cp -Rp /etc/quagga/* /usr/backups-data/$DIRNAME/quagga/"
echo "cp -Rp /etc/apache2/* /usr/backups-data/$DIRNAME/apache2/"
echo "cp -p /etc/ntp.conf /usr/backups-data/$DIRNAME/"
echo "cp -p /etc/dhcpd.conf /usr/backups-data/$DIRNAME/"
echo "cp -p /etc/fstab /usr/backups-data/$DIRNAME/"

# Backup the web server files (redirection)
echo "cp -Rp /srv/www/htdocs/* /usr/backups-data/$DIRNAME/htdocs"
echo "cp -Rp /srv/www/alumni/* /usr/backups-data/$DIRNAME/alumni"

What am I doing wrong??

TIA!

Craig Wolf
Linux Web Server Support
Desktop/Network Specialist
402-715-6283



More information about the OLUG mailing list