Wednesday, October 29, 2008

MxBackup

I wrote my first iPhone application!

My 22-month old daughter loves to play with my iPhone. In particular, she likes MxTube, a YouTube downloader app, available if you Jailbreak your iPhone. After a while, she tends to delete my downloaded videos because her click and swipe coordination need some work.

So, I've written an app that backs up my videos and restores them whenever I need to. Ignore the "Background Enabled" message- that pops up when I try to take a screenshot because of another app I have installed.



11 comments:

nudel said...
This comment has been removed by the author.
nudel said...

a great little utility! :)

u mention that the scripts can be modified to FTP the files to a network server. that sounds perfect as i could then watch them on my PC or XBOX.

can u give an example of how to modify to do this? e.g. to a NAT server on the same network

Jeremy said...

nudel,

If you look inside the unix file system on your phone, you should find /Applications/MxBackup.app/Backup.sh

This is the shell script that performs the backup when you click "Backup". To ftp each file to an anonymous file server, you could do something like:



#!/bin/bash

BACKUP=/var/mobile/backup/MxTube
MXTUBE=/private/var/mobile/Media/MxTube
VIDEOLIST=/private/var/mobile/Library/MxTube/VideoLibrary.plist

# check that the directory exists for backup
if [ ! -d "$BACKUP" ]; then
mkdir -p "$BACKUP"
if [ $? -eq 0 ]; then
echo "Created new directory for backup."
else
echo "Unable to create new directory for backup."
exit 1
fi
fi

# backup the listing file
cp $VIDEOLIST ${BACKUP}/VideoLibrary.plist
if [ $? -ne 0 ]; then
echo "Unable to backup VideoLibrary.plist"
exit 1
fi

echo "Backed up Video Library List."

for file in `ls $MXTUBE`; do
if [ ! -e ${BACKUP}/$file ]; then
cp ${MXTUBE}/$file ${BACKUP}
echo "Backed up $file."
fi

# backup every file to ftp server
ftp yourserverip<<EOF
user anonymous anonymous@mydomain.org
bin
put $file
quit
EOF

done

echo "Backup complete."

nudel said...

thanks i'll try it.

btw, i have tried a number of times the normal backup operation (without modification) but there is no /var/mobile/backup/MxTube folder created & therefore no backed up files even tho the app finishes & shows the green text indicating all files have been backed-up - see screen-shot here: http://img301.imageshack.us/img301/1309/20090302001.png

i've looked for 'backup' folder in other locations but nothing.

also tried adding the /backup/MxTube structure to /var/mobile but still no files are backed-up.

here is the unmodified backup.sh script that is installed:

#!/bin/bash

# backup the listing file
cp /private/var/mobile/Library/MxTube/VideoLibrary.plist /var/mobile/backup/MxTube
echo "Backed up Video Library List."

for file in `ls /private/var/mobile/Media/MxTube`; do
if [ ! -e /var/mobile/backup/MxTube/$file ]; then
cp /private/var/mobile/Media/MxTube/$file /var/mobile/backup/MxTube
echo "Backed up $file."
fi
done

Jeremy said...

Yeah, I sent in an update to Backup.sh and Restore.sh shortly after releasing the original version. It should appear in Cydia today, I imagine.

The latest version of Backup.sh auto-creates that directory if it doesn't exist. It's basically the script you see from my post, minus the "ftp" logic. The Restore.sh is also changed a little:

#!/bin/bash

BACKUP=/var/mobile/backup/MxTube
MXTUBE=/private/var/mobile/Media/MxTube
VIDEOLIST=/private/var/mobile/Library/MxTube/VideoLibrary.plist

# copy each file that's not found
for file in `ls $BACKUP`; do
if [ ! -e ${MXTUBE}/$file ]; then
cp ${BACKUP}/$file ${MXTUBE}
echo "Restored $file."
fi
done

# restore video list
if [ -e ${BACKUP}/VideoLibrary.plist ]; then
cp ${BACKUP}/VideoLibrary.plist ${VIDEOLIST}
echo "Restored Video Library list."
fi

nudel said...

thanks a bunch - that works! :)

Anonymous said...

Hi !.
might , perhaps very interested to know how one can collect a huge starting capital .
There is no initial capital needed You may begin to get income with as small sum of money as 20-100 dollars.

AimTrust is what you haven`t ever dreamt of such a chance to become rich
The firm represents an offshore structure with advanced asset management technologies in production and delivery of pipes for oil and gas.

It is based in Panama with offices everywhere: In USA, Canada, Cyprus.
Do you want to become a happy investor?
That`s your choice That`s what you wish in the long run!

I feel good, I started to take up real money with the help of this company,
and I invite you to do the same. If it gets down to select a proper partner utilizes your money in a right way - that`s AimTrust!.
I make 2G daily, and what I started with was a funny sum of 500 bucks!
It`s easy to get involved , just click this link http://evuwyvyze.greatnow.com/rytaqys.html
and lucky you`re! Let`s take our chance together to get rid of nastiness of the life

Anonymous said...

Hi!
You may probably be very curious to know how one can make real money on investments.
There is no need to invest much at first.
You may begin to get income with a money that usually goes
for daily food, that's 20-100 dollars.
I have been participating in one project for several years,
and I'm ready to share my secrets at my blog.

Please visit blog and send me private message to get the info.

P.S. I make 1000-2000 per daily now.

http://theinvestblog.com [url=http://theinvestblog.com]Online Investment Blog[/url]

Anonymous said...

The information here is great. I will invite my friends here.

Thanks

Anonymous said...

Good day, sun shines!
There have were times of hardship when I felt unhappy missing knowledge about opportunities of getting high yields on investments. I was a dump and downright stupid person.
I have never thought that there weren't any need in large initial investment.
Nowadays, I feel good, I begin take up real money.
It gets down to select a correct partner who utilizes your money in a right way - that is incorporate it in real deals, parts and divides the profit with me.

You can get interested, if there are such firms? I have to answer the truth, YES, there are. Please get to know about one of them:
http://theinvestblog.com [url=http://theinvestblog.com]Online Investment Blog[/url]

MxTube-Lover said...

Since folders in MxTube changed, can you please update MxBackup?

Old:
/private/var/mobile/Library/mxtube/VideoLibrary.plist

New: /private/var/mobile/Library/Preferences/VideoLibrary.plist

The Thumbnails (.thm) are now in "Preferences" folder, too!

This folder must be corrected in the two script files:
/Applications/MxBackup.app/Backup.sh and Restore.sh