View Single Post
Old January 18th, 2013, 10:56 AM   #1 (permalink)
SUroot
ROM Developer
Thread Author (OP)
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,326 Times in 3,995 Posts
Default [Profile] [Root] Auto Nandroid backup Manager

Inspired by Silentwitness' question here:

help with nandroid backup via tasker

I wrote this profile / script and have created a thread for it.Content

Contents

Who is this profile for?
What does this profile do exactly?
What do I need to know / understand before using this profile?
What is included in this "Profile"?
The Script
Note to S3 users
Note to Other device users
I want to change this to use my External SD card. How?
Download


Who is this profile for?

This profile has been created for root users. In particular, those who use a ClockWorkMod (CWM) based recovery to take Nandroid backups. A Nandroid backup is a complete image (or snapshot if you will) of the phone at the time it is taken. When a Nandroid backup is restored, the phone is returned to exactly* as it was when the backup was taken.

* Some elements aren't backed up on all devices, such as the Radio/Modem/Baseband


What does this profile do exactly?

This profile will Automatically create a Nandroid backup, every Saturday at 04:00 (am). It boots into recovery, takes the backup and then boots back into Android.

This profile has a 2 week backup retention, so you will always have a maximum of 2 backups, the oldest one being deleted before the new one is taken.

You can also add a widget to the homescreen:

Long press home screen > Add Widget > Task > nandroid

This will allow you to take a backup (and reboot automatically) from your homescreen directly. The Schedule will not be overridden, however, the oldest backup will have been replaced.

WARNING - There is no confirmation on this as yet. Pressing it will immediately boot into recovery. I recommend if you can spare a homescreen to this on its own, please do so.


What do I need to know / understand before using this profile?

To use this profile, you need to know the mount points on your phone both in android and recovery.

For example, on the s3 there is an internal and an external SD card.

In android (S3) these are:
internal - /mnt/sdcard
external - /mnt/extSdCard

In CWM recovery (S3) these are:
internal - /data/media
external - /external_sd

First you must decide if you are going to use the Internal or External SD card.

On a phone that has NO external sdcard, you would follow the rationale of the S3's internal sdcard (/mnt/sdcard in android).

Similarly if you have a phone that has NO internal sdcard, you would still follow the rationale of the internal sdcard (/mnt/sdcard in android).

Essentially EVERY device will use /mnt/sdcard for their Storage, whether that's an external Micro SD card or Internal SD card. Only devices that have an internal AND external SD card will need to look into that deeper.

People with root explorers can browse to the root of their device, find the /mnt directory and see what everything is mounted as. You will be able to get everything you need to use for the "in Android" settings. As for recovery, this could vary from device to device so if you don't know, ask in the development thread (Probably XDA) of your device's recovery.

Note. Mount points are case sensitive. /mnt/extsdcard will not work if it's supposed to be /mnt/extSdCard


What is included in this "Profile"?

The profile consists of 2 elements.

1) The tasker Profile
2) The nandroid.sh script (that needs to be in /mnt/sdcard/clockworkmod/)

Both of these elements are in the attached zip file.


The Script

This script by default uses /mnt/sdcard/clockworkmod/backup as the backup location.

This is the Internal SD card for devices that have both an internal AND external SD card.

This is the External SD card for devices that ONLY have an external SD card.

The backup MUST go in the clockworkmod/backup folder because if it does not, your recovery will not be able to restore the backups. It works best on the /mnt/sdcard directory because this is universal for all devices. However, some devices wipe the internal SD when factory resetting from the Android menu (Galaxy S3), so only reset from recovery.

Here is an extract of the script (and what it does):

Code:
# Set today's date
now=$(date +"%d_%m_%y-%H:%M")

# Deletes previous archive (as contained within index1.txt)
rm -rf $(cat /mnt/sdcard/clockworkmod/backup/index1.txt)

# Moves previous backup to archive (index2 becomes index1 for delete next time)
mv /mnt/sdcard/clockworkmod/backup/index2.txt /mnt/sdcard/clockworkmod/backup/index1.txt

# Stamps new index 2
echo '/mnt/sdcard/clockworkmod/backup/'$now > /mnt/sdcard/clockworkmod/backup/index2.txt

# writes a command for recovery to read (creates index2 backup)
echo 'backup_rom("/data/media/clockworkmod/backup/'$now'");' > /cache/recovery/extendedcommand

Note to S3 users

If you are happy with using the internal SD card for backups, this profile and script can be used unmodified.

Note to Other device users

If you are happy with using the default location of /mnt/sdcard, this script will require minimal modification. Please note that the last command of the script as show below:

Code:
backup_rom("/data/media/clockworkmod/backup/'$now'");
Is where the S3's CWM recovery mounts the /mnt/sdcard (as /data/media). This will most likely be different on otehr devices so you need ensure you know your equivelant.

See again: What do I need to know / understand before using this profile?


I want to change this to use my External SD card. How?

OK, I'll tell you how. Firstly, I will write this as if it was asked by an S3 user because I know the relevant alternative mount points in Android and recovery for this device.

If you do not know your mount points, see again: What do I need to know / understand before using this profile?


1. Modifying the script.

Its best to do this on a computer. Use a notepad or text application that has a "Find and replace" function.

Find: mnt/sdcard
Replace: mnt/extSdCard

Find: data/media
Replace: external_sd

The script now needs to be put into /mnt/extSdCard/clockworkmod/backup

2. Modifying the profile

Well, it's actually editing the task but hey ho...

Open step 1. of the task. Change /mnt/sdcard/ to /mnt/extSdCard/ and save the task / profile.

That's it...



Downloads
Attached Files
File Type: zip nandroid2.zip (994 Bytes, 117 views)
SUroot is offline  
Last edited by SUroot; February 5th, 2013 at 09:55 AM.
Reply With Quote
The Following 7 Users Say Thank You to SUroot For This Useful Post:
D-U-R-X (December 18th, 2013), DragonSlayer95 (January 18th, 2013), electricpete (January 21st, 2013), jobics (March 23rd, 2014), kennymck (May 6th, 2013), silentwitness (January 18th, 2013), simonwil (February 5th, 2013)