Solved

Rsync progress question

Posted on 2013-01-28
8
595 Views
Last Modified: 2013-01-31
I’m backing up my VM’s from my storage server to external HDD for offsite backup.  I’m trying to monitor how the progress is going, but despite what appears to be the right parameter, I’m not seeing it.  I’ve created a script with a command for each of the dirs that uses a supplied parameter (the date stamp on the backup dir) for each directory.  At the end I want it to shoot me an email.  My command is called backup.sh.  I’m running it as root, sh backup.sh 2013-01-25_04-00-00

The backup.sh looks like this inside:

rsync -r -v --progress /mnt/storage/nfs/ocl_nfs_1/backups/server1/server1-$1 /media/external/server1 | mail -s "RSync Job Log" iamhere@work.ca

(more server backups follow this one, each using the same command with the names changed.)

I’m sure there’s a better way to do this.  I’m running this on Openfiler 2.99 2.6.32-131.17.1.el6-0.11.smp.gcc4.4.x86_64.  (based on rPath)

also, if there's a faster way to transfer to a USB device other than Rynsc that will still mail me a log when completed I'd appreciate any additional input.
0
Comment
Question by:clicker666
  • 4
  • 3
8 Comments
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 38829743
Way outside the scope of this question:
If you moved to a zfs based storage (zfsguru.com is what I recommend but there are others) you can make snapshots and send them to another zfs box. For non zfs stuff you can rsync with snapshots like so:
http://forums.freebsd.org/showthread.php?t=11971

Just something I mention to people running NSF shares on non-zfs storage like openfiler.
0
 
LVL 1

Author Comment

by:clicker666
ID: 38830608
I found my own answer.  This parameter seems to break the onscreen progress indicators.   | mail -s "RSync Job Log" iamhere@work.ca  Since it wasn't actually sending me email I suppose I can live without it for now.
0
 
LVL 1

Author Comment

by:clicker666
ID: 38837246
I've requested that this question be closed as follows:

Accepted answer: 0 points for clicker666's comment #a38830608

for the following reason:

Although I fixed my own problem, it stops me from receiving email logs of the jobs.  I will have to research and revisit that side - but for now I will manually run the jobs and monitor their progress.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 20

Expert Comment

by:Daniel McAllister
ID: 38835262
Sorry I came late to this one... hope I'm not too late...

Your issue is that you want the output to go both to the screen and to the mail program.

At first glance, I'd suggest using the 'tee' utility (reads standard in, sends a copy to stdout, and another copy to a specified file).... but I don't think that will work, as the real "break" comes from the fact that your output is being directed to a pipe at all.

Still, without having a system to try it on, I might suggest something like:
rsync -r -v --progress /mnt/storage/nfs/ocl_nfs_1/backups/server1/server1-$1 /media/external/server1 | tee /tmp/mailout.tmp ; mail -s "RSync Job Log" iamhere@work.ca < /tmp/mailout.tmp

This would allow the interactive output to the screen, while still capturing it for output to the mail program.

Just a thought...

Dan
IT4SOHO

PS: I won't object to just closing the question ... but if the solution works, it would be sporting to award points :-)
0
 
LVL 1

Author Comment

by:clicker666
ID: 38836533
IT4SOHO almost has it.  Can we reopen?

That does send me an email when done, the only issue is that it comes in as Subject: RSync Job Log, but the attachment gets renamed as RSync Job Log.dat.  Is there a way to specify the attachment name in the command line?  It's almost perfect.
0
 
LVL 20

Expert Comment

by:Daniel McAllister
ID: 38837247
I can stop the cancellation request....

Dan
IT4SOHO
0
 
LVL 20

Accepted Solution

by:
Daniel McAllister earned 250 total points
ID: 38837290
Hmmm... I'm actually a little surprised that the e-mail content is showing up as an attachment...

Perhaps if we "seed the file" a little (that is, create some interesting first lines)...

Try something like:
echo "" > /tmp/mailout.tmp
echo "Starting backup with rsync at `date +"%r %Z"` >> /tmp/mailout.tmp
rsync -r -v --progress /mnt/storage/nfs/ocl_nfs_1/backups/server1/server1-$1 /media/external/server1 | tee -a /tmp/mailout.tmp
echo "" >> /tmp/mailout.tmp
mail -s "RSync Job Log" iamhere@work.ca < /tmp/mailout.tmp

Once you get this working, you may want to remove the /tmp file at the end :-)

Dan
IT4SOHO
0
 
LVL 1

Author Comment

by:clicker666
ID: 38839483
That works.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to fix error ""Failed to validate the vCentre certificate. Either install or verify the certificate by using the vSphere Data Protection Configuration utility" when you are trying to connect to VDP instance from Vcenter.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question