#!/usr/bin/perl use strict; use warnings; $| = 1; my $rsync_cmd = "/usr/local/bin/rsync -aNHAXxv --exclude-from=/Users/user/rsync-exclude --protect-args --fileflags --force-change --password-file=/Users/user/rsync-pwd"; my $rsync_dst = "rsync_dst_ip::user"; my $user = "/Users/user"; my $rsync_src = "/Volumes/DATA/ $user/Desktop $user/Documents $user/Library"; my $fh; open($fh, "$rsync_cmd $rsync_src $rsync_dst 2>&1 |") or die "rsync error: $!"; open (MAIL, "|/usr/sbin/sendmail vincent\@brc.ubc.ca") or die "open error: $!"; print MAIL "From: user\@rsync_src_ip\n"; print MAIL "Subject: user RSYNC BACKUP REPORT\n\n"; while(<$fh>) { print MAIL $_; } close(MAIL) || warn "Error closing mail:$!";