LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices



Reply
 
Search this Thread
Old 03-26-2005, 05:08 AM   #1
robinhood1995
Member
 
Registered: Jan 2002
Location: Ohio
Distribution: CentOS 5.2
Posts: 52

Rep: Reputation: 15
Backup Script from Multiple Drives to one Big Drive


Hi All,

I didn't know if this would be usful to anyone but I made a script to backup three drive onto one 200gig drive.

Code:
#!/bin/bash
###############################################################################
#
# Weekly Backup Script for Liunx box
# This will copy all files to another drive
#
###############################################################################
#
#Set the Date for the file
DATE=`date +%F_%H%M%S`
INSTALL_DIR=/u2/back
LOGS=/u2/back
LOGNAME=Weekly_backup_$DATE.log
EXCLUDES=backup_exclude
STORAGE=/u3/osbkup
#
# This cd to the root folder
cd /
# This mounts the drive
mount /dev/hdb1 /u3
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" > $LOGS/$LOGNAME
echo -e "Started the Daily backup `date`" >> $LOGS/$LOGNAME
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >> $LOGS/$LOGNAME
echo -e " "
#
###############################################################################
#
# This will make copy on the drive
#
# This is the root section "The -vaux commant is to stay in one file system 
# and only update the file that are newer
cp -vaux /bin /boot /etc /ftp /home /initrd /KIWI /lib /misc /mnt /opt /root /sbin /tftpboot /tmp /usr /var /u3/osbkup/ >> $LOGS/$LOGNAME
cd /u
cp -vaux /u/* /u3/osbkup/u/ >> $LOGS/$LOGNAME
cd /u2
cp -vaux /u2/* /u3/osbkup/u2/ >> $LOGS/$LOGNAME
#
echo -e " "
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >> $LOGS/$LOGNAME
echo -e "Ended the Daily backup `date`" >> $LOGS/$LOGNAME
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >> $LOGS/$LOGNAME
echo -e " "
#
###############################################################################
#
#This will list out the files to a log file.
#
echo -e "Creating the Daily backup file list `date`" >> $LOGS/$LOGNAME
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >> $LOGS/$LOGNAME
echo -e " "
ls -l $STORAGE/* >> $LOGS/$LOGNAME.txt
echo -e " "
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >> $LOGS/$LOGNAME
echo -e "Ended the Daily backup file list `date`" >> $LOGS/$LOGNAME
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >> $LOGS/$LOGNAME
echo -e "Stopped the Daily backup `date`" >> $LOGS/$LOGNAME
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >> $LOGS/$LOGNAME
chmod 666 $LOGS/$LOGNAME
#
echo -e "Emailed the Daily backup results `date`" >> $LOGS/$LOGNAME
echo -e "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" >> $LOGS/$LOGNAME
#
# This emails that user
/usr/bin/mutt "" -a $LOGS/$LOGNAME.txt -a $LOGS/$LOGNAME -s "Daily Backup Log" johndoe@whereever.com < /dev/null
#
# This unmounts the drive
umount /u3
#
##############################################################################
 
Old 03-26-2005, 06:58 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
Consider using rsync instead of 'cp'. Since most of the content that you are copying will not change between backups, rsync will be much faster (it only copies changes). You also have additional controls, allowing remote copy via ssh, and bandwidth limiting, for example. Rsync isn't just for remote use.

For example, instead of:

cp -vaux /bin /boot /etc /ftp /home /initrd /KIWI /lib /misc /mnt /opt /root /sbin /tftpboot /tmp /usr /var /u3/osbkup/ >> $LOGS/$LOGNAME

Use:

/usr/bin/rsync -av --delete /bin /boot /etc /ftp /home /initrd /KIWI /lib /misc /mnt /opt /root /sbin /tftpboot /tmp /usr /var /u3/osbkup/ >> $LOGS/$LOGNAME
 
Old 03-26-2005, 10:31 AM   #3
robinhood1995
Member
 
Registered: Jan 2002
Location: Ohio
Distribution: CentOS 5.2
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by macemoneta
/usr/bin/rsync -av --delete /bin /boot /etc /ftp /home /initrd /KIWI /lib /misc /mnt /opt /root /sbin /tftpboot /tmp /usr /var /u3/osbkup/ >> $LOGS/$LOGNAME
Hi macemoneta,

My drives are local so not really any bandwithd required. But I thought that "rsync" was only used for remote or samba connections is this correct?

Thanks
 
Old 03-26-2005, 10:47 AM   #4
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Moved: More suitable in our Success Stories forum.
 
Old 03-26-2005, 11:33 AM   #5
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 328Reputation: 328Reputation: 328Reputation: 328
Quote:
Originally posted by robinhood1995
Hi macemoneta,

My drives are local so not really any bandwithd required. But I thought that "rsync" was only used for remote or samba connections is this correct?

Thanks
No, rsync can copy files locally as well. I use it almost exclusively for moving large media files, with the "--progress" option to see estimated time to completion, and '--partial', so that I can interrupt the operation and complete it later if needed (picking up where it left off). It's also comforting to know that the source and destination are verified the same. The extra speed (when updating) doesn't hurt either.

I have an alias defined for interactive use:

alias rsync='/usr/bin/rsync -av --progress --partial'

You certainly don't need to use a bandwidth limit when copying to an external drive, however, if that drives is also used for other concurrent purposes, limiting bandwidth can be beneficial. For example, if the drive is used to store and playback music/movies, monopolizing the bandwidth can cause "stuttering" playback. You could then use the bandwidth limit to leave adequate bandwidth for media streaming. For example:

/usr/bin/rsync -av --delete --bwlimit=5000 ... ...

This will keep rsync to about 5MB/sec.
 
Old 03-26-2005, 07:17 PM   #6
robinhood1995
Member
 
Registered: Jan 2002
Location: Ohio
Distribution: CentOS 5.2
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by macemoneta
This will keep rsync to about 5MB/sec.
Thanks,

Will try it out...
 
  


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
cdrecord script for multiple cd-rw drives Avian00 Linux - Software 27 09-14-2010 11:50 AM
best way to backup file server drives? terahybrid Linux - General 6 10-12-2005 02:55 AM
Big, big hard drive in a little, little tablet... pengyou Linux - Laptop and Netbook 6 10-18-2004 04:44 AM
Bash backup script - If multiple files starting with a exist problem demoncheese Programming 2 07-29-2004 11:47 PM
Is there support for tape backup drives? Belkorin Fedora 0 07-09-2004 11:57 AM


All times are GMT -5. The time now is 06:03 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