I’ve been stumbling around for awhile on this, and I’m throwing in the towel and asking for help. This isn’t strictly a KM question, although I’m sure I’ll write a macro to launch it, so I’m hoping that’s good enough. 
I have a Raspberry Pi with multiple Samba shares. I want to sync (to my Mac) multiple folders on each of those shares. Basically I want to back them up. And I want to do it without having to remember to mount the shares, etc. - I want the script/macro/whatever to do this all for me.
Example:
###Pi:###
Name: retropie
Connect as: Guest
Share: config
Folder(s) to sync (read): /all/emulationstation/downloaded_images
###Mac:###
Folder(s) to sync to (write): ~/Documents/Raspberry/Backups/config/all/emulationstation/downloaded_images
I hope this is enough information. I’ve gotten myself a little confused, so bear with me. 
Thanks for any help. By the way, I don’t care what actual method I use to do the sync, as long as it works.
This is the script I use for backing up a remove volume to another remote volume.
Since there is an rsync in this script, use with extreme caution.
#!/usr/bin/perl
use lib $ENV{HOME}."/perl";
use warnings;
use strict;
use diagnostics;
my $source = '/Volumes/XDrive';
my $dest = '/Volumes/Shared/XDriveCopy';
system( 'open', '-g', 'afp://wombat.synology.me/XDrive' );
system( 'open', '-g', 'afp://NAS._afpovertcp._tcp.local/Shared' );
{
alarm 20;
local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
while ( ! -d $source || ! -d $dest || count_dir( $source ) < 5 || count_dir( $dest ) < 5 ) { ; }
alarm 0;
}
System( 'rsync',
'--verbose', '--itemize-changes', '--progress',
'--recursive', '--times', '--links',
'--delete',
'--modify-window=2',
'--backup', "--backup-dir=$dest/#backups",
'--exclude=#recycle', '--exclude=#backups', '--exclude=.*', '--exclude=Icon?',
"$source/", $dest
);
# , '--dry-run'
sub System {
print join( ' ', @_ ), "\n";
system( @_ );
}
sub count_dir {
my( $dir ) = @_;
my $count = 0;
opendir( DIR, $dir ) or die "cant open dir $dir $!";
foreach ( readdir( DIR ) ) {
s!.*/!!;
next if m!^\.!;
next if $_ eq "Icon\015";
$count++;
}
# print STDERR "count_dir $dir -> $count\n";
return $count;
}
1 Like