rsync script

Kaushal Shriyan kaushalshriyan at gmail.com
Fri Mar 21 16:40:38 UTC 2008


On Fri, Mar 21, 2008 at 12:58 PM, Res <res at ausics.net> wrote:

> On Fri, 21 Mar 2008, Kaushal Shriyan wrote:
>
> > Hi
> >
> > MAILTO=kaushal at example.com
> > 0 18 * * * rsync -av /var/lib/mysql kaushal at host77:/var/lib/
> >
> > If i put this two lines in crontab it will run correctly,My requirement
> was
> > to create a script, this script should indicate success or failures and
> the
> > reason for failure
>
>
> Seriously, you would be *far* better off using mysqldump then any form of
> rsync/cp etc.. You may expect problems relying on an rsync version, the
> risk might be low, but it is still there, hence why we have mysqldump :)
> It would be safer to do a mysqldump then scp the dump file.
>
> But if you must.. this could go in /etc/cron.daily/weekly/whatever
>
> #!/usr/bin/perl
> use Mail::Sendmail;
>
> $RSYNC = "/usr/bin/rsync -vazr --stats --password-file=/etc/rsync.secret
> --delete-after --delete /var/lib/ kaushal\@host77:/var/lib/";
>
> system("$RSYNC") == 0 or warn &RSFuk("transfer problem");
>
> sub RSFuk {
>   my ($rfail) = @_;
> $MSG = qq[
> Error report says: $rfail
> ];
>
> %mailme = ( To  => 'user at email.address',
>         From    => 'rsync at some.host',
>         Subject => 'mysql  backupfailed',
>         Message => $MSG
>         );
> sendmail(%mailme);
>
>
>
>
> --
> Cheers
> Res
>
> mysql> update auth set Framed-IP-Address='127.0.0.127' where user=
> 'troll';
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>

Hi Res

so what i understand from your email is to put the below code in a text file
and name it as rsync_mysql.pl script and enter the below 2 lines in crontab
-e

MAILTO=kaushal at example.com
0 18 * * * rsync_mysql.pl

##################################################################
#!/usr/bin/perl
use Mail::Sendmail;

$RSYNC = "/usr/bin/rsync -vazr --stats --password-file=/etc/rsync
>
> .secret
> --delete-after --delete /var/lib/ kaushal\@host77:/var/lib/";
>
> system("$RSYNC") == 0 or warn &RSFuk("transfer problem");
>
> sub RSFuk {
>   my ($rfail) = @_;
> $MSG = qq[
> Error report says: $rfail
> ];
>
> %mailme = ( To  => 'user at email.address',
>         From    => 'rsync at some.host',
>         Subject => 'mysql  backupfailed',
>         Message => $MSG
>         );
> sendmail(%mailme);
> ##################################################################
>
> Also I did not understand the From Address in the above perl script ( From
   => 'rsync at some.host', ) , what would be the address in this scenario

Awaiting your earnest reply

Thanks and Regards

Kaushal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20080321/4bcd9a2b/attachment.html>


More information about the ubuntu-users mailing list