LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices



Reply
 
Search this Thread
Old 06-04-2005, 12:54 AM   #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, 05:46 PM   #2
sgl
LQ Newbie
 
Registered: Dec 2004
Posts: 25

Rep: Reputation: 15
TODAY=\"date +%D\"

you need backticks there to execute the date command.

take the backslash out from the quotes, for the varaibles that you just want to assign strings to.

also consider rsync for backups, and see:

http://www.mikerubel.org/computers/rsync_snapshots/

hope this helps you get started with shell programming!

Steve
 
  


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


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


All times are GMT -5. The time now is 01:02 PM.

Main Menu
Advertisement
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