LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 06-04-2005, 12:11 PM   #1
stlyz3
Member
 
Registered: Mar 2005
Posts: 54

Rep: Reputation: 15
Backing Up Server


Hello everyone,

My company has several servers and we want to backup the production web servers to a dedicated server box. I have written a backupscript that I wanted to use but I got a slew of errors. Here is the script:

#!/bin/bash

TODAY=\"date +%D\"
TODAY2=\"date +%m%d%Y\"
EMAIL=\"backupadmin@domain.com\"
BACKDIR=\"/root/backup\"
MYSQLUSR=\"root\"
MYSQLPSD=\"999999\"
DB=\"--alldatabases\"
FILE=\"server_backup\"
CHK=\"chkrootkit\"
RKH=\"rkhunter\"

cd $BACKDIR
mysqldump -u $MYSQLUSR -p $MYSQLPSD $DB > $FILE_$TODAY2
rkhunter -c > $RKH_$TODAY2
cd /root/chkrootkit-0.45/
./chkrootkit > $BACKDIR/$CHK_$TODAY2
cd $BACKDIR

tar czf $FILE_temp_$TODAY2.tar.gz $FILE_$TODAY2 $RKH_$TODAY2 $CHK_TODAY2 /home | gpg -c > $FILE_$TODAY2.tar.gz
rm $RKH_$TODAY2
rm $FILE_$TODAY2
rm $CHK_$TODAY2
rm $FILE_temp_$TODAY2.tar.gz

date | mutt -s \"$FILE ($TODAY) \" -a $FILE_$TODAY2.tar.gz $EMAIL

When I run the script, using ./script.sh I get the following set of errors:

[root@localhost ~]# ./script.sh
./brawn_daily_bckup.sh: line 3: +%D": command not found
./brawn_daily_bckup.sh: line 4: +%m%d%Y": command not found
./brawn_daily_bckup.sh: line 14: cd: "/root/backup": No such file or directory
./brawn_daily_bckup.sh: line 15: $FILE_$TODAY2: ambiguous redirect
./brawn_daily_bckup.sh: line 16: $RKH_$TODAY2: ambiguous redirect
./brawn_daily_bckup.sh: line 18: "/root/backup"/: No such file or directory
./brawn_daily_bckup.sh: line 19: cd: "/root/backup": No such file or directory
gpg: failed to create temporary file `/root/.gnupg/.#lk0x552ac57250.localhost.lo
caldomain.16254': No such file or directory
gpg: keyblock resource `/root/.gnupg/pubring.gpg': general error
Enter passphrase: tar: Removing leading `/' from member names
gpg: can't create `/root/.gnupg/random_seed': No such file or directory
rm: too few arguments
Try `rm --help' for more information.
rm: too few arguments
Try `rm --help' for more information.
rm: too few arguments
Try `rm --help' for more information.
[root@localhost ~]# ls

What I am trying to do is to run Rkhunter and Chkrootkit and give them their own text file. Then make a mysql backup and a backup of the home directory. All these files get tarred then encrypted. All files that were used prior are then deleted.

Can someone please tell me what I did wrong? Any help will be greatly appreciated.
 
Old 06-04-2005, 01:25 PM   #2
saman007uk
Member
 
Registered: Dec 2003
Location: ~root
Distribution: Debian
Posts: 363

Rep: Reputation: 32
Quote:
./brawn_daily_bckup.sh: line 3: +%D": command not found
./brawn_daily_bckup.sh: line 4: +%m%d%Y": command not found
./brawn_daily_bckup.sh: line 14: cd: "/root/backup": No such file or directory
./brawn_daily_bckup.sh: line 15: $FILE_$TODAY2: ambiguous redirect
./brawn_daily_bckup.sh: line 16: $RKH_$TODAY2: ambiguous redirect
./brawn_daily_bckup.sh: line 18: "/root/backup"/: No such file or directory
./brawn_daily_bckup.sh: line 19: cd: "/root/backup": No such file or directoryj
TO fix the erros for those, remove the '/' from variables and use ' (single quotation) instead of " (double quotation marks).
 
Old 06-04-2005, 01:27 PM   #3
shaitand
Member
 
Registered: Jun 2005
Posts: 54

Rep: Reputation: 15
your biggest problem seems to be quoting, why are you escaping the quotes when assigning the variables values? You need the quotes to escape the special shell characters. You also should be using single quotes otherwise some of the shell characters might still be interpreted.


Here is some shell output to illustrate the point


shaitan@mike:~> TODAY='date +%D'
shaitan@mike:~> echo $TODAY
date +%D
shaitan@mike:~> TODAY=\"date +%D\"
bash: +%D": command not found
 
Old 06-04-2005, 10:04 PM   #4
stlyz3
Member
 
Registered: Mar 2005
Posts: 54

Original Poster
Rep: Reputation: 15
So is this what it should say?

TODAY='date +%D'
TODAY2='date +%m%d%Y'
EMAIL='backupadmin@domain.com'
BACKDIR='/root/backup'
MYSQLUSR='root'
MYSQLPSD='999999'
DB='--alldatabases'
FILE='server_backup'
CHK='chkrootkit'
RKH='rkhunter'
 
Old 06-04-2005, 10:44 PM   #5
shaitand
Member
 
Registered: Jun 2005
Posts: 54

Rep: Reputation: 15
Quote:
Originally posted by stlyz3
So is this what it should say?

TODAY='date +%D'
TODAY2='date +%m%d%Y'
EMAIL='backupadmin@domain.com'
BACKDIR='/root/backup'
MYSQLUSR='root'
MYSQLPSD='999999'
DB='--alldatabases'
FILE='server_backup'
CHK='chkrootkit'
RKH='rkhunter'
Looks good at a glance. If there are any other errors in your script the errors will probably make a lot more sense now. I did not see any at a glance.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Server vs. Backing up date fredmt Linux - General 7 11-02-2005 08:11 AM
Backing Up Server stlyz3 Linux - Enterprise 1 06-04-2005 04:46 PM
Backing up a Slackware server technician Slackware 3 03-09-2005 01:50 PM
Backing up of a RH8 server without root axx p0 theed Linux - Networking 27 07-07-2003 02:38 PM
Backing up Linux to a remote server! DigiCrime Linux - General 5 12-10-2002 03:41 AM


All times are GMT -5. The time now is 02:59 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration