Go Back   Android Forums > Android Phones > HTC EVO 4G > EVO 4G - All Things Root
EVO 4G - All Things Root Rooting, ROMS, Overclocking, etc.
Gamers - Check out our new sister sites!
Nintendo Wii U!    |    OUYA - $99 Android System!

test: Reply
 
LinkBack Thread Tools
Old April 17th, 2012, 11:45 PM   #1 (permalink)
no place like ~
Thread Author (OP)
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: /home/
Posts: 4,759
 
Device(s): Galaxy S3 (Verizon) Evo 4G - retired/rooted
Carrier: Verizon

Thanks: 3,031
Thanked 1,721 Times in 1,162 Posts
Send a message via AIM to 9to5cynic
Default Nandroid Backup Script

Okay, so this is a script to backup the nandroids on your phone.
Requirements:
  • Linux (it's a bash script)
  • USB mode for your phone

I thought of this as kinda an automated process, so a cronjob.

It seems to be working with both AMON RA and CLOCKWORKMOD recoveries. I sent it off to marc12868 to see if clockwork works with someone who actually *has* clockwork installed [if he says it doesn't work, then i'll fix it]. I just set up a folder to mimic the folder structures. It should work.

If you want to run it each time, which works, then you only need to change the two variables phone and backup. $phone is just where your device is mounted. Mine was /media/0A00-1234 or something like that. $backup is the (you guessed it) backup directory.

Steps
  • Save this script somewhere ($HOME/nandroid.sh)
  • grant it execute permissions (chmod +x nandroid.sh)
  • either run it (./nandroid.sh) or
  • get it working with cron (below)
CRON:






Nandroid Backup Script:






more words





9to5cynic is offline  
Last edited by 9to5cynic; April 30th, 2012 at 10:56 PM. Reason: updated script link
Reply With Quote
The Following 5 Users Say Thank You to 9to5cynic For This Useful Post:
argedion (April 18th, 2012), Granite1 (April 18th, 2012), ocnbrze (April 18th, 2012), Rxpert83 (April 18th, 2012), Tresezk (April 18th, 2012)
Sponsors
Old April 18th, 2012, 12:21 AM   #2 (permalink)
DON'T PANIC!!!!!!!!!
 
ocnbrze's Avatar
 
Join Date: May 2010
Location: los angeles
Gender: Male
Posts: 19,131
 
Device(s): HTC Evo 4g LTE, HTC 3vo(no longer have), HTC EVO (not activated)
Carrier: Sprint

Thanks: 21,746
Thanked 11,554 Times in 7,479 Posts
ocnbrze@gmail.com
Default

ohhh nice!!!!
gonna have to play with this this weekend.
__________________
“The Guide is definitive. Reality is frequently inaccurate.”.......Hitchhiker's Guide to the Universe
“I seldom end up where I wanted to go, but almost always end up where I need to be.”.......Douglas Adams
ocnbrze is offline  
Reply With Quote
The Following User Says Thank You to ocnbrze For This Useful Post:
9to5cynic (April 18th, 2012)
Old April 18th, 2012, 12:31 AM   #3 (permalink)
no place like ~
Thread Author (OP)
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: /home/
Posts: 4,759
 
Device(s): Galaxy S3 (Verizon) Evo 4G - retired/rooted
Carrier: Verizon

Thanks: 3,031
Thanked 1,721 Times in 1,162 Posts
Send a message via AIM to 9to5cynic
Default

Let me know how it goes. And if you just want to try it, you can skip the cron step and just do it via terminal .... ./backup.sh

If you have a lot of nandroids, it'll be slow.... (it copies the nandroid to /tmp, then from /tmp it goes to your backup drive and compresses it) ... but that's why I thought having it start by itself would be nice, it'll copy the nandroid over while you charge or something.

just some time trials - I copied two nandroids (total: 1.2 GB) to the tar.gz files (680MB) in about 4-7 minutes [I didn't see exactly when I started it]
9to5cynic is offline  
Last edited by 9to5cynic; April 18th, 2012 at 12:37 AM.
Reply With Quote
The Following User Says Thank You to 9to5cynic For This Useful Post:
ocnbrze (April 18th, 2012)
Old April 18th, 2012, 07:07 AM   #4 (permalink)
Resident Frog
 
argedion's Avatar
 
Join Date: Jun 2011
Location: The Severed Garden
Posts: 4,638
 
Device(s): HTC EVO 4g(Retired), HTC EVO LTE(Retired), LG Lucid(Returned), Motorola Droid Razr M, Nexus 7
Carrier: GOD

Thanks: 4,063
Thanked 4,258 Times in 2,093 Posts
Default

one of the main reason i wrote mine in script was so that while it was doing the backups I could continue to do other things. Do note that even though you can run these as a normal user its best practice to run them as the root user. root gets preference. Besides it will prevent any errors on stuff you don't have permission to do. Once I have mine in the final stages I'll post it. Right now its in semifinal stages. I still am finding ways to clean it up and improve it.

Also Note Windows Users You can Use BATCH to accomplish alot of the same thing however it will be different than using Linux and the Bash system.
__________________
All My Links In one Convenient Place
Asking simple questions can keep us from doing dumb things.
Help BabyBlues save the ta ta's
argedion is online now  
Reply With Quote
The Following User Says Thank You to argedion For This Useful Post:
ocnbrze (April 18th, 2012)
Old April 18th, 2012, 10:52 AM   #5 (permalink)
Resident Frog
 
argedion's Avatar
 
Join Date: Jun 2011
Location: The Severed Garden
Posts: 4,638
 
Device(s): HTC EVO 4g(Retired), HTC EVO LTE(Retired), LG Lucid(Returned), Motorola Droid Razr M, Nexus 7
Carrier: GOD

Thanks: 4,063
Thanked 4,258 Times in 2,093 Posts
Default

Not sure about most of the xplorers today but I know Nautilus has gone pretty much graphical so you don't get the classic text address bar that you used to. With Nautilus all you have to do is press ctrl + L and it will show up for the session others may offer similar shortcuts such as this.
argedion is online now  
Reply With Quote
The Following User Says Thank You to argedion For This Useful Post:
ocnbrze (April 18th, 2012)
Old April 18th, 2012, 01:15 PM   #6 (permalink)
Stand Back!
 
Rxpert83's Avatar
 
Join Date: Aug 2011
Location: MN
Posts: 12,151
 
Device(s): EVO 4g, EVO 4G LTE, Nexus S, Galaxy Nexus, S3, Nexus 7
Carrier: Not Provided

Thanks: 9,296
Thanked 9,265 Times in 5,272 Posts
Default

I don't know what any of this is.... BUT great job!


All kidding aside... this looks like it would be very useful to our linux users.
Rxpert83 is online now  
Reply With Quote
The Following User Says Thank You to Rxpert83 For This Useful Post:
9to5cynic (April 18th, 2012)
Old April 18th, 2012, 08:05 PM   #7 (permalink)
no place like ~
Thread Author (OP)
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: /home/
Posts: 4,759
 
Device(s): Galaxy S3 (Verizon) Evo 4G - retired/rooted
Carrier: Verizon

Thanks: 3,031
Thanked 1,721 Times in 1,162 Posts
Send a message via AIM to 9to5cynic
Default

Quote:
Originally Posted by Rxpert83 View Post
I don't know what any of this is.... BUT great job!


All kidding aside... this looks like it would be very useful to our linux users.


Also, I'm thinking of adding on to it so it will check to see if that backup file already exists...

What I mean by that is say you have your Stock 2.2 backup (showing my age ), no point in backing that up every time, once it is in the backup dir, it should be ignored. So, I think that's my next step.
9to5cynic is offline  
Reply With Quote
The Following 2 Users Say Thank You to 9to5cynic For This Useful Post:
argedion (April 18th, 2012), Rxpert83 (April 18th, 2012)
Old April 18th, 2012, 08:27 PM   #8 (permalink)
Resident Frog
 
argedion's Avatar
 
Join Date: Jun 2011
Location: The Severed Garden
Posts: 4,638
 
Device(s): HTC EVO 4g(Retired), HTC EVO LTE(Retired), LG Lucid(Returned), Motorola Droid Razr M, Nexus 7
Carrier: GOD

Thanks: 4,063
Thanked 4,258 Times in 2,093 Posts
Default

Quote:
Originally Posted by 9to5cynic View Post


Also, I'm thinking of adding on to it so it will check to see if that backup file already exists...

What I mean by that is say you have your Stock 2.2 backup (showing my age ), no point in backing that up every time, once it is in the backup dir, it should be ignored. So, I think that's my next step.
Good idea thats why in mine I'm trying to remove them from the card after backing them up have run into a few snags with that it maybe because i'm not running it as root though i'm going to run it as root and see if that solves the issue. was also thinking of doing a check to make sure you were the root user to avoid issues with the script.
argedion is online now  
Reply With Quote
Old April 18th, 2012, 08:36 PM   #9 (permalink)
no place like ~
Thread Author (OP)
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: /home/
Posts: 4,759
 
Device(s): Galaxy S3 (Verizon) Evo 4G - retired/rooted
Carrier: Verizon

Thanks: 3,031
Thanked 1,721 Times in 1,162 Posts
Send a message via AIM to 9to5cynic
Default

Quote:
Originally Posted by argedion View Post
Good idea thats why in mine I'm trying to remove them from the card after backing them up have run into a few snags with that it maybe because i'm not running it as root though i'm going to run it as root and see if that solves the issue. was also thinking of doing a check to make sure you were the root user to avoid issues with the script.
removing them isn't a bad idea, but I'd hate to remove *all* of them, then have to remove the sd card to get a nandroid back on there.... maybe something where it will remove all but one..?

checking for root would be pretty easy - something like this:
Code:
var=$(id -u)
if [[ $var -eq 0 ]]
then
echo 'root'
else
echo 'not root'
fi
Though, I ran mine from my user account if I recall correctly...
But, I wrote the majority of it in LM (as opposed to debian) and it gave an error with the df -k line - something about needing root permissions to analyze a part of a hidden file for root.... I ignored it. I think the script still ran without it.

--

Okay, I have it remove each file now, but it still leaves the nandroid folder empty (no backup) - I could get it to keep one (but that would need to be assigned by the script and checked in a loop...).

Also, I don't think I said this, but it *should* work on any phone that uses a similar nandroid structure. IE: /device/nandroid/#####/ABC-######/ It doesn't look at the name of the directories in bold.
9to5cynic is offline  
Last edited by 9to5cynic; April 18th, 2012 at 08:55 PM.
Reply With Quote
Old April 18th, 2012, 09:13 PM   #10 (permalink)
Resident Frog
 
argedion's Avatar
 
Join Date: Jun 2011
Location: The Severed Garden
Posts: 4,638
 
Device(s): HTC EVO 4g(Retired), HTC EVO LTE(Retired), LG Lucid(Returned), Motorola Droid Razr M, Nexus 7
Carrier: GOD

Thanks: 4,063
Thanked 4,258 Times in 2,093 Posts
Default

Quote:
Originally Posted by 9to5cynic View Post
removing them isn't a bad idea, but I'd hate to remove *all* of them, then have to remove the sd card to get a nandroid back on there.... maybe something where it will remove all but one..?

checking for root would be pretty easy - something like this:
Code:
var=$(id -u)
if [[ $var -eq 0 ]]
then
echo 'root'
else
echo 'not root'
fi
Though, I ran mine from my user account if I recall correctly...
But, I wrote the majority of it in LM (as opposed to debian) and it gave an error with the df -k line - something about needing root permissions to analyze a part of a hidden file for root.... I ignored it. I think the script still ran without it.

--

Okay, I have it remove each file now, but it still leaves the nandroid folder empty (no backup) - I could get it to keep one (but that would need to be assigned by the script and checked in a loop...).

Also, I don't think I said this, but it *should* work on any phone that uses a similar nandroid structure. IE: /device/nandroid/#####/ABC-######/ It doesn't look at the name of the directories in bold.
Honestly I keep at most up to 3 Nandroids on the Phone and only up to about 6 on the computer after that they are really to old for me to restore. I have updates almost every day for this app or that app. by the end of the week I have updated about 15 to 20 apps. so really when I restore a nandroid its generally nothing real old and i only have a small amount of stuff to update again. for the most part I keep titanium backup fresh and keep a good copy of my favorite ROM on the card. This is as important as the Nandroid.

Yeah the root check isn't hard to do. Also if your using bash it shouldn't matter if your using LM, Debian, Ubuntu, or even Fedora its still going to be the same. they have the same bash rules.
argedion is online now  
Reply With Quote
Sponsors
Old April 18th, 2012, 09:30 PM   #11 (permalink)
no place like ~
Thread Author (OP)
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: /home/
Posts: 4,759
 
Device(s): Galaxy S3 (Verizon) Evo 4G - retired/rooted
Carrier: Verizon

Thanks: 3,031
Thanked 1,721 Times in 1,162 Posts
Send a message via AIM to 9to5cynic
Default

Quote:
Originally Posted by argedion View Post
Yeah the root check isn't hard to do. Also if your using bash it shouldn't matter if your using LM, Debian, Ubuntu, or even Fedora its still going to be the same. they have the same bash rules.
yeah, they all look for /etc/profile or ~/.bash_profile or ~/.bashrc
but it was with how LM was handling df -k specifically.

df: `/root/.gvfs': Permission denied


but that doesn't actually seem to mess with the script at all. And I am working on getting it to check to see if the files are there in tar.gz format... I'm hoping to have some more time this weekend - but finals are coming up so I'll be a bit busy.



--
(I think I might be getting there, wrote down what I'm thinking on paper - gotta get some sleep)
9to5cynic is offline  
Last edited by 9to5cynic; April 18th, 2012 at 09:44 PM. Reason: edit1
Reply With Quote
Old April 19th, 2012, 08:46 PM   #12 (permalink)
Resident Frog
 
argedion's Avatar
 
Join Date: Jun 2011
Location: The Severed Garden
Posts: 4,638
 
Device(s): HTC EVO 4g(Retired), HTC EVO LTE(Retired), LG Lucid(Returned), Motorola Droid Razr M, Nexus 7
Carrier: GOD

Thanks: 4,063
Thanked 4,258 Times in 2,093 Posts
Default

Quote:
Originally Posted by 9to5cynic View Post
yeah, they all look for /etc/profile or ~/.bash_profile or ~/.bashrc
but it was with how LM was handling df -k specifically.

df: `/root/.gvfs': Permission denied


but that doesn't actually seem to mess with the script at all. And I am working on getting it to check to see if the files are there in tar.gz format... I'm hoping to have some more time this weekend - but finals are coming up so I'll be a bit busy.



--
(I think I might be getting there, wrote down what I'm thinking on paper - gotta get some sleep)
Finals First We have plenty of time to make this work correctly afterwords ok? Ok.

gvfs is a private file system for network file systems. basically it connects your home folder to the network "privately" I'm not exactly sure how it works but had someone much smarter than me explain it to me (Ok attempted to explain it to me) I got lost so basically told her to stop I didnt need an explaination that bad I wish I new where she was now though she was a wiz at all this stuff and the one responsible for getting me into Linux in the first place.

Ok for the rest of you

It shouldnt matter what version of linux your using but what is important that you are using BASH. This also can be done from a live environment however you will need to save it to an external hard drive or even to a thumb drive that has a larger capacity than your SDCARD. You can also expand it to go beyond the nandroid I'll be posting one here soon for you to manipulate for your use. Probably release it under GPL 3 but then again may just put it out there under an honor code we'll see.
argedion is online now  
Reply With Quote
Old April 29th, 2012, 10:02 PM   #13 (permalink)
no place like ~
Thread Author (OP)
 
9to5cynic's Avatar
 
Join Date: Feb 2011
Location: /home/
Posts: 4,759
 
Device(s): Galaxy S3 (Verizon) Evo 4G - retired/rooted
Carrier: Verizon

Thanks: 3,031
Thanked 1,721 Times in 1,162 Posts
Send a message via AIM to 9to5cynic
Default

Okay, I think I have this working now. It still removes all the backups that you have, but eh...

As of now it'll check the content of the backup folder, and check that against the nandroid folder on your phone. It also will find that phone's serial number (according to the nandroid folder) so that's kinda cool.

If your nandroids match, it'll ignore them (and leave them intact - so that works for the stock backups after you already have it through this script). If they don't match, it'll copy and remove them.

here's the code





!!!
Remember to change your variables as you see fit. I think I go into that pretty well in the first post.

I just was suggested to make it compatible with clockwork, so I'll be doing that next. Should be simple, but I just turned everything off. Tomorrow!
9to5cynic is offline  
Last edited by 9to5cynic; April 29th, 2012 at 10:33 PM.
Reply With Quote
Old April 30th, 2012, 03:34 PM   #14 (permalink)
Resident Frog
 
argedion's Avatar
 
Join Date: Jun 2011
Location: The Severed Garden
Posts: 4,638
 
Device(s): HTC EVO 4g(Retired), HTC EVO LTE(Retired), LG Lucid(Returned), Motorola Droid Razr M, Nexus 7
Carrier: GOD

Thanks: 4,063
Thanked 4,258 Times in 2,093 Posts
Default

Quote:
Originally Posted by 9to5cynic View Post
Okay, I think I have this working now. It still removes all the backups that you have, but eh...

As of now it'll check the content of the backup folder, and check that against the nandroid folder on your phone. It also will find that phone's serial number (according to the nandroid folder) so that's kinda cool.

If your nandroids match, it'll ignore them (and leave them intact - so that works for the stock backups after you already have it through this script). If they don't match, it'll copy and remove them.

here's the code





!!!
Remember to change your variables as you see fit. I think I go into that pretty well in the first post.

I just was suggested to make it compatible with clockwork, so I'll be doing that next. Should be simple, but I just turned everything off. Tomorrow!
Looks good I'm still tweaking the one I am working on along with a ton of other things I'm doing.
argedion is online now  
Reply With Quote
Reply
Tags
backup, bash, linux, nandroid, script


Go Back   Android Forums > Android Phones > HTC EVO 4G > EVO 4G - All Things Root
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:44 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.