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.
|