Skip to content

Instantly share code, notes, and snippets.

@bortels
Created January 20, 2014 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bortels/8527587 to your computer and use it in GitHub Desktop.
Save bortels/8527587 to your computer and use it in GitHub Desktop.
Backup my jailbroken iPad nightly to my unix box
#!/usr/bin/perl
# Backup ipad app Documents folders in a sane manner
# Expects public key login (ie. no password) as user "mobile"
$dest = '/backups/ipaddocs';
$find = 'find ./ -maxdepth 2 -name "*.app" -type d';
$appdir = '/private/var/mobile/Applications';
open (I, "ssh -n mobile\@192.168.1.86 'cd $appdir ; $find' |");
# Example output: ./F2C36A80-4F02-404F-B589-48362E6A6F52/Tiny Wings HD.app
while (<I>) {
@r = split(/\//);
$hash = $r[1];
$name = $r[2];
$name =~ s/.app\n$//;
$name =~ s/[^\w]/_/cg;
$DB{$hash} = $name;
}
$total = scalar(keys %DB);
$n=0;
foreach (keys %DB) {
$n++;
print "===== $n of $total : $DB{$_}\n";
$hash = $_;
$name = $DB{$hash};
system("mkdir -p $dest/$name-$hash");
system("rsync -avz --progress mobile\@192.168.1.86:$appdir/$hash/Documents $dest/$name-$hash");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment