maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Script to backup /home/user/* (https://talk.maemo.org/showthread.php?t=53415)

lemmyslender 2010-05-23 18:21

Script to backup /home/user/*
 
Just ran into an interesting problem this morning. Rebooted my N900 and plugged the charger in once it hit the Nokia screen.

For some reason when it had finished booting, my contacts/calendar were gone, widgets were all reset to defaults, some weren't showing.

It appears that all or part of my /home/user directory disappeared. Widget settings were gone, etc. All my applications were still installed, but all the settings stored in /user/ were gone.

In particular, the comics widget got reset, pretty annoying to start over reading comics from january (particularly since the comics are in the MyDocs folder. Fortunately, I had a backup from about 2 weeks ago, so I only had to go through the last 2 weeks of comics.

I also had to redo settings for many other programs (ermining, alarmed, etc). Email was ok.

Anyway, I wrote a quick script to backup /home/user (excluding MyDocs), that I can schedule to run through alarmed (or any other scheduling app). It checks to make sure the N900 is charging before running. Just thought I'd post it here for anyone else interested.

I'm sure there are better ways to do this, feel free to modify all you want.

Code:

#! /bin/sh

ischarging=`hal-device bme | grep is_charging | awk '{print $3}'`
if [ $ischarging = "true" ]; then
        tar -cvf /home/user/MyDocs/tmp/user.tar /home/user --exclude "MyDocs"
#        tar -cvf /home/user/MyDocs/tmp/opt.tar /opt
fi

*EDIT* it also has a line to backup /opt as well (obviously)

qole 2010-05-28 05:31

Re: Script to backup /home/user/*
 
This is great to use before reflashing. Thanks.

toughcanny 2010-07-13 17:27

Re: Script to backup /home/user/*
 
hi lemmyslender

thanks for such a script, and i really would like to backup using this script, but unfortunately, i dont know how to run this script

can you please guide me into running this script, some step by steps procedure

lemmyslender 2010-07-13 18:28

Re: Script to backup /home/user/*
 
Open xterm, create a folder called scripts (mkdir scripts), if you want (Xterm should open in /home/user).

Change to scripts directory (cd scripts).

Open your favorite editor (leafpad, nano, vi) and paste the script into it.

Save the file as backup.sh

Add the execute permission to the backup (chmod +x backup.sh)

Execute the script ( ./backup.sh) It won't work unless your N900 is charging (plugged in).

*Make sure to create a tmp directory in your MyDocs folder if it isn't there already.
*Remove the # to backup /opt as well.

You should see a list of files start scrolling by. It'll take a bit to run depending on the sizes involved.

No warranties expressed, implied, etc.

EDIT -Also, although you can open *.tar files in windows (with the right programs), extracting the files will cause their permissions to be lost. You can use Xarchiver on the N900 to open and extract files.
You should restore files from user.tar as the normal user, files from opt.tar as root. Otherwise, you may screw up permissions on the files.

RobbieThe1st 2010-09-09 00:24

Re: Script to backup /home/user/*
 
Have you tested trying to restore the /opt/ directory? I'm not sure how well it would work when you have apps running(in the background if nowhere else).

Also, do realize that if you end up restoring to PR1.2, then restore your /opt/ directory, you -will not- be able to use any programs you restored, -unless- you install them all first.

lemmyslender 2010-09-09 12:12

Re: Script to backup /home/user/*
 
Well, I was initially looking to backup /home/user/* as several apps keep settings and files there. Once I got that, I threw in /opt/* for fun. MyDocs can be copied via usb, so I wasn't as worried about that.

I never planned on doing a "full restore" (un-tar back to /opt or /home/user), I was using it more to pick and choose a couple/several files to restore. Given the size (max 2GB) I figured it was easier to do the whole thing, as opposed to guessing what I'd mess up next.

For a while I was doing quite a bit of modding, and occasionally screwed something up. At least a couple times, I was able to go through the backup, pull out a file(s) and replace a corrupted/missing file(s) via ssh.

*I would not recommend doing a full restore, unless you know what you are doing as it may destroy your N900* :)


All times are GMT. The time now is 07:52.

vBulletin® Version 3.8.8