LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-15-2011, 09:40 AM   #1
musiqdefunk
LQ Newbie
 
Registered: Mar 2011
Posts: 22

Rep: Reputation: 0
Perl and Rsync


I have a rsync script written in Perl which rsync's a dmp file but it's been taking 7 hours longer than usual... how do I go about add a print to the rsync so i can see the progress in a log...

use POSIX qw/strftime/;

$export_dir = "/oracle/path";
$remote_dir = "/oracle/path";
$cur_date = strftime "%Y%m%d", localtime time;

chdir( $export_dir ) or die "Can't chdir to $export_dir $!";

my $dump = "AP1_fullexp2_$cur_date.dmp";
if (-e $dump) {
`/bin/su - oracle -c "rsync -zpogv --progress $export_dir/$dump oracle\@IPADRESS:$remote_dir/"`;
} else {
die "$dump export does not exist. \n";

thanks
 
Old 09-15-2011, 09:57 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Use something more like:
Code:
    open( RSYNC "/bin/su - oracle -c \"rsync -zpogv --progress $export_dir/$dump oracle\@IPADRESS:$remote_dir/\" |" );
    while( <RSYNC> ){
        print $_;
    }
--- rod.
 
Old 09-21-2011, 11:42 AM   #3
musiqdefunk
LQ Newbie
 
Registered: Mar 2011
Posts: 22

Original Poster
Rep: Reputation: 0
Ok so I'm done with Perl, it's just not my cup of tea. So I decided to just rewrite the script in Bash.

It works but I have 2 more complicated things I would like it to do, one I would like for it to rerun if the rsync fails and 2 I would like an output of the files I am deleting.

Code:
export_dir="/oracle/path"
remote_dir="/u04/path"
archive_dir="/oracle_exports/path"
date=`date +%Y%m%d`
dump="fullexp_$date.dmp"

cd $export_dir
if [ -f $dump ]; then
        /bin/su - oracle -c "rsync -navz --progress $export_dir/$dump oracle@ipaddress:$remote_dir/" > $export_dir/db_rsync$date.log;
else
        echo "$dump export does not exist"
fi

exit 0

find ${export_dir} -name '*.bz2' -mtime +31 -type f exec rm -rf {} \;

cd $archive_dir

find $(archive_dir} -name '*.bz2' -mtime +360 -type f exec rm -rf {} \;
 
  


Reply



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
rsync solaris + ld.so.1: rsync: fatal: libiconv.so.2: open failed: xxx_anuj_xxx Solaris / OpenSolaris 25 02-23-2012 03:23 AM
[SOLVED] rsync execution issue with crontab - Have given full path to rsync too!! Prabagaran Linux - Server 6 04-15-2011 01:39 AM
rsync as root + perl question sir-lancealot Linux - Server 2 02-14-2011 09:22 PM
[SOLVED] rsync fails in cron - ssh key prob for rsync? jonathansfl Linux - Server 6 12-09-2010 09:48 AM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:46 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
Open Source Consulting | Domain Registration