full system backup script


 
Thread Tools Search this Thread
Operating Systems Linux full system backup script
# 1  
Old 11-17-2007
full system backup script

Please help. I am new to linux. I wrote a script to run the backup on lunix machine but the job gave me an error. I am using Linux 2.6.14.3. Below is the sample of my script can anyone tell me where went wrong? Thanks in advance.

#!/bin/sh

dat=$(date +%d%b%y)
logdir="/usr/local/scripts/log/backup"
backuptarget="/*"
backupdir="/usr/hell/backups"

for HOST in devil1 devil2 devil3
do

ssh $HOST "tar -zcvpf $backupdir/$HOST.$dat.tgz $backuptarget --exclude "/usr/hell/DB" >> $backupdir/$HOST.backup.log.$dat "

ssh $HOST "cat $backupdir/$HOST.backup.log.$dat" >> $logdir/"$HOST.backup.log.$dat"
gzip $logdir/"$HOST.backup.log.$dat"

scp root@$HOST:$backupdir/$HOST.$dat.tgz $backupdir

# scp exits with 0 on success or >0 if an error occurred.

if [ $? -gt 0 ]; then
/var/netpage OPERATIONS -TSMS -G10.200.1.99 "$HOST scp failed"
fi

/bin/tar ztvf $backupdir/$HOST.$dat.tgz ||/var/netpage OPERATIONS -TSMS -G10.201.2.66 "$HOST.$dat.tgz is no good"

ssh $HOST "rm -f $backupdir/*"

done


/bin/tar -zcvpf $backupdir/devil1.$dat.tgz /* --exclude "/usr/hell/backups/*" --exclude "/usr/hell/DB/*" --exclude "/usr/dragon/.cache/*" >> $logdir/"devil1.backup.log.$dat"

gzip $logdir/"devil1.backup.log.$dat"

/bin/tar ztvf $backupdir/devil1.$dat.tgz ||/var/netpage OPERATIONS -TSMS -G10.200.1.99 "devil1.$dat.tgz is no good"

#zip up /usr/hell/backups directory as windows bkf file is big
gzip $backupdir/*

/bin/tar -rvpf /dev/st0 $backupdir/* /usr/hell/DB/200[4-6]*/* --exclude "*log*" >> $logdir/"tape.backup.log.$dat"
/bin/gzip $logdir/"tape.backup.log.$dat"
rm -f $backupdir/*
# 2  
Old 11-17-2007
What is the error?

Thanks,

Joe
# 3  
Old 11-20-2007
The below is the error message

"$HOST scp failed"
"$HOST.$dat.tgz is no good"
# 4  
Old 11-21-2007
Your scp is failing here. Can you manually scp anything from root@devil1?

Try this (from the server where the script runs):

scp root@devil1:/etc/motd /tmp/motd.devil1

If this fails, you might need to look at the ssh configuration.

I also noticed that you are only running the scp as root. What user are the other ssh commands running as?
# 5  
Old 11-22-2007
Quote:
Originally Posted by blowtorch
Your scp is failing here. Can you manually scp anything from root@devil1?

Try this (from the server where the script runs):

scp root@devil1:/etc/motd /tmp/motd.devil1

If this fails, you might need to look at the ssh configuration.

I also noticed that you are only running the scp as root. What user are the other ssh commands running as?
I only run as root.Will try the above.
# 6  
Old 11-27-2007
Quote:
Originally Posted by blowtorch
Your scp is failing here. Can you manually scp anything from root@devil1?

Try this (from the server where the script runs):

scp root@devil1:/etc/motd /tmp/motd.devil1

If this fails, you might need to look at the ssh configuration.

I also noticed that you are only running the scp as root. What user are the other ssh commands running as?
I have try the above command and it work.

the error is "$HOST.$dat.tgz is no good" if run the backup script
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Help - Chosing backup way (full system + zones)

Hello i am new on Solaris, and i need to migrate my old AIX 5.3 to Solaris 11.2 Now i have all apps working fine but i have the backup cause i was reading and i have not idea about what method must i choose. Btw on AIX i had a mksysb backup to restore all system and obviously another backups to... (4 Replies)
Discussion started by: thorin666
4 Replies

2. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

3. UNIX for Advanced & Expert Users

Grub - how to boot a copy of Linux (full system backup)

Hi All, I have successfully backup & restore (using tar) one of my Debian Lenny Servers. On the restore server (standby machine), everytime i have to erase the disk & extract the tar backup. I want to extract the tar on the running restore server on a directory for e.g /systembackup-01,... (11 Replies)
Discussion started by: coolatt
11 Replies

4. UNIX for Advanced & Expert Users

how to make a full system backup excluding data and restoring it to a new system

Hi, In order to have a sand box machine that I could use to test some system changes before going to production state, I'd like to duplicate a working system to a virtual one. Ideally, I'd like to manage to do it this way : - Make a full system backup excluding the user file system (this... (7 Replies)
Discussion started by: pagaille
7 Replies

5. HP-UX

HP-UX Full System Backup with fbackup

Hello, I'm still new in HP-UX backup and I want to do a FULL BACKUP of HP-UX server to TAPE device. After reading on several forums and posts, i have list down several steps on how to do a full backup on HP-UX with fbackup. I would like the gurus here to comment/advise on the steps below 1)... (4 Replies)
Discussion started by: miskin
4 Replies

6. UNIX for Dummies Questions & Answers

Full System Backup Sco 5.0.5

I would like to know if I can do a full system back up on my Unix Sco openserver 5.0.5 Machine. If so, What is the syntax to do this or where can I find this information at? Also, is it possible to make this tape bootable so that I can easily do a full system restore? Any information on... (2 Replies)
Discussion started by: nellenodrog
2 Replies

7. Solaris

full system backup

I have unix server with OS 5.8 ,,, I tried ufsdump 0ua -f /dev/rmt/0 / to perform full system backup on tape but I failed could any one give a procedure for full system backup on solaris machine using tapes??? (1 Reply)
Discussion started by: mm00123
1 Replies

8. UNIX for Dummies Questions & Answers

System full backup to tape

hi, Recently, I had receive one system. it's run on the unix tru64 server. I looking some log files when i know don't work few months age system backup to tape. Below error: INFO:Tape backups to tape tape0 starting for backup list: slot2:/disk4 Backup Command Variable... (0 Replies)
Discussion started by: Tlg13team
0 Replies

9. UNIX for Dummies Questions & Answers

Full System Backup / Cloning HPUX

I am new to UNIX and need help in cloning a HPUX 10.2 Ace 5, can anybody please guide me in making a full system backup. Real Chess (0 Replies)
Discussion started by: real-chess
0 Replies
Login or Register to Ask a Question