partha chowdhury
2008-Dec-27 07:14 UTC
[CentOS] Beginner - need suggestion to improve BACKUP script
hallo list,
I have recently started to learn shell scripting. Now
i am trying to write a script to backup /etc and /var to my home dir in
a separate folder and then backup the home dir to usb drive using rsync.
My goal is when i will run the script it will output status to standard
output in form of bold messages with time and simultaneously logs to
another file in /root dir. I have labled the usb drive as
"usb-mass-storage". the script runs fine according to my requirement.
Now i need suggestion to improve the script further. Thank you.
the script is as follows:
> #!/bin/sh
> if blkid |grep USB-Mass-Storage
> then
> if [ -d /media/backup ]
> then
> /bin/mount LABEL=USB-Mass-Storage /media/backup
> echo
"-------------------------------------------------------------------------
" >> /root/backup.log
> echo $(date) >> /root/backup.log
> /etc/rc.d/init.d/named stop &> /dev/null
> echo "CONFIGURATION backup starting "|tee -a /root/backup.log
> /usr/bin/rsync -a --progress --delete /etc/ ~freedom/backup/etc/ >>
/root/backup.log;echo "CONFIGURATION backup finished" |tee -a
/root/backup.log;echo "VARIABLE backup starting"|tee -a
/root/backup.log;/usr/bin/rsync -a --progress --delete --exclude=ftp/pub/media/
/var/ ~freedom/backup/var/ >> /root/backup.log; echo "VARIABLE backup
finished" |tee -a /root/backup.log;/etc/rc.d/init.d/named start&>
/dev/null
> echo " Now we are going to backup $(date)" |tee -a
/root/backup.log
> /usr/bin/rsync -a --progress --delete /home/freedom/ /media/backup/ |tee -a
/root/backup.log; echo "BACKUP FINISHED $(date)" |tee -a
/root/backup.log
> else
> echo "$(date) DISTDIR does not exist" |tee -a /root/backup.log
> fi
> else
> echo "$(date) USB drive not entered"|tee -a /root/backup.log
> fi
1>the /root/backup.log is the log file
2>i stop the named service before starting backup as i run the named
process in a chroooted environment and if i trey to manually backup
/var with rsync i get :/var/named/chroot/proc/kcore: <file> has vanished !
3>my home dir is /home/freedom
4>i exclude the /var/ftp/pub/media/ folder as it is just the copy of
centos 5 dvd which i use as my local base repo.
jkinz at kinz.org
2008-Dec-27 12:58 UTC
[CentOS] Beginner - need suggestion to improve BACKUP script
On Sat, Dec 27, 2008 at 12:44:21PM +0530, partha chowdhury wrote:> 2>i stop the named service before starting backup as i run the named > process in a chroooted environment and if i trey to manually backup > /var with rsync i get :/var/named/chroot/proc/kcore: <file> has vanished !Always exclude /var/named/chroot/proc/ from your backups. backing it up isn't needed. See: https://www.linuxquestions.org/questions/linux-general-1/prockcore-what-is-it-14251/ Jeff Kinz --
Kai Schaetzl
2008-Dec-27 14:31 UTC
[CentOS] Beginner - need suggestion to improve BACKUP script
Partha chowdhury wrote on Sat, 27 Dec 2008 12:44:21 +0530:> the script is as follows:Next time put this in original format on a website, spares download bandwidth for those that don't want to see it and aching eyes for those that want to see it. Kai -- Kai Sch?tzl, Berlin, Germany Get your web at Conactive Internet Services: http://www.conactive.com