iPhone and Linux

Wednesday, November 11, 2009

A simple backup script

Unfortunately, this can't run from a SpringBoard icon as it takes too long to execute. iPhone apps are supposed to tell the system when they've finished loading or else the system assumes they're hung and kills them. I'm looking for a workaround, as I have 3 scripts I want to run that way but which get killed every time.

To use this script, put a list of files you want to back up in /var/mobile/backuplist. It will copy them to /var/mobile/backup/, tar and bzip2 them, then scp them to your computer using ssh keys, which I explained earlier. It could obviously use regular scp if you don't mind typing the password.
#! /bin/sh 
cd /var/mobile
while read line; do cp -r $line /var/mobile/backup/; done < backuplist
tar -cf backup.tar /var/mobile/backup
bzip2 backup.tar
scp -i ~/.ssh/KEY ~/backup.tar.bz2 USER@IP:/PATH/TO/DESTINATION
rm -rf backup
rm backup.*

Blog Archive