[olug] Script help

Craig Wolf cjwolf at mpsomaha.org
Sun Dec 28 23:55:38 UTC 2008


That was it!!  Thanx for the help!!  I figured it was something simple but the book I am learning from did not mention that as a gotcha.  8)



Craig Wolf
Linux Web Server Support
Desktop/Network Specialist
402-715-6283
>>> Kevin <sharpestmarble at gmail.com> 12/28/08 5:39 PM >>>
First thing I see wrong, that correcting will result in a different
error message: There are spaces surrounding your equals sign. Remove
them and it will result in assigning to DIRNAME the following:
"backup_", sans quotes. This assumes that date is an empty variable.
You will also need to tell bash to run the date command by placing
them in parenthesis.

DIRNAME="backup_$(date +%Y-%m%d)" to give "backup_2008-1228", sans quotes.
or
DIRNAME="backup_$(date +%F)" to give "backup_2008-12-28", also sans quotes.


On Sun, Dec 28, 2008 at 17:22, Craig Wolf <cjwolf at mpsomaha.org> wrote:
> 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
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> https://lists.olug.org/mailman/listinfo/olug
>
_______________________________________________
OLUG mailing list
OLUG at olug.org
https://lists.olug.org/mailman/listinfo/olug




More information about the OLUG mailing list