Manual backup and restore

(Email (modest))
Line 1: Line 1:
-
=Manual Backup And Restore=
+
There are several scenarios where you might want to manually backup and restore your phone. Using manual methods (as opposed to using osso-backup) is convenient for advanced users (to have more control over their phone), scheduling backups with fcron and the like, starting from scratch (if you want to wipe the phone and restore file-by-file) - because osso-backup can backup also problematic files.
-
This process was discussed [http://talk.maemo.org/showthread.php?t=35037 at talk.maemo.org]
+
This was discussed at [http://talk.maemo.org/showthread.php?t=35037 talk.maemo.org].
-
There are several scenarios where you might want to backup and manually restore your tablet.
+
==Backup methods==
-
'''accidental damage to configurations'''
+
===Copying===
-
you accidentally deleted something, or you loaned it to someone who does.
+
This script backs up contacts, conversations, calendar, bookmarks, repository and packages list to external memory card's directory Backup which then contains subdirectories named with date and time when the backup was performed. For example: "Memory_card/Backup/2010-03-03 00-00". It also displays notification during backup, because it was made to be used with fcron.
-
'''fresh start from scratch'''
+
#!/bin/sh
 +
run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Making backup..."
 +
date=`date +"%F %H-%M"`
 +
mkdir -p /media/mmc1/Backup/"$date"/home/user/.bookmarks
 +
mkdir /media/mmc1/Backup/"$date"/home/user/.calendar
 +
mkdir /media/mmc1/Backup/"$date"/home/user/.osso-abook
 +
mkdir /media/mmc1/Backup/"$date"/home/user/.osso-abook-backup
 +
mkdir -p /media/mmc1/Backup/"$date"/var/lib/hildon-application-manager
 +
cp /home/user/.bookmarks/MyBookmarks.xml* /media/mmc1/Backup/"$date"/home/user/.bookmarks
 +
cp /home/user/.calendar/calendardb /media/mmc1/Backup/"$date"/home/user/.calendar
 +
cp -r /home/user/.osso-abook/db /media/mmc1/Backup/"$date"/home/user/.osso-abook
 +
cp -r /home/user/.osso-abook-backup/db /media/mmc1/Backup/"$date"/home/user/.osso-abook-backup
 +
cp -r /home/user/.rtcom-eventlogger /media/mmc1/Backup/"$date"/home/user
 +
cp /var/lib/hildon-application-manager/catalogues* /media/mmc1/Backup/"$date"/var/lib/hildon-application-manager
 +
cp /var/lib/hildon-application-manager/packages.backup /media/mmc1/Backup/"$date"/var/lib/hildon-application-manager
 +
run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Backup created"
-
You've hacked around your tablet so much you want to back it up, wipe it clean and restore bit by bit, rather than use the standard whole-system backup/restore which could revert the problems too! You want to back up the entire tablet, excluding only things you definitely don't need rather than try and cherry pick things, and then restore specific files and directories.
+
===osso-backup (what is backed up by it)===
-
==Backing up the entire tablet==
+
osso-backup is the default Backup application on the phone. You can use it for "manual" backup, because it produces standard .zip compressed files which can be opened on any system. The list of files that osso-backup backs up can be obtained by making a backup with it and opening these zip files (the list is too long for this wiki page).
-
The best program to use is "rsync" - this program is in the maemo extras repository. A suitable backup script is shown below, save it to /usr/local/bin/backup as a plain text file. You can then "chmod ugo+x /usr/local/bin/backup" and run it (as root please). Change "mypc.example.com" to the hostname (or IP address) of your computer, and the target directory from /home/archive/blahblah to /whatever. Note the "dpkg -l" to get a list of installed packages, this will help you remember what you had installed! The "gconf" bit lists out all the wifi access points defined so that you can copy/paste the details back in later.
+
===rsync===
-
<pre>
+
rsync is standard Linux/Unix file and directory synchronization tool. It is in extras repository. An example backup script is shown here:
-
#!/bin/sh
+
-
dpkg -l > /root/dpkg-l.txt
+
#!/bin/sh
 +
 +
dpkg -l > /root/dpkg.txt
 +
 +
gconftool-2 -R /system/osso/connectivity/IAP > /root/iap.txt
 +
 +
rsync  -avz                    \
 +
        --exclude=/dev          \
 +
        --exclude=/media        \
 +
        --exclude=/mnt/initfs  \
 +
        --exclude=/proc        \
 +
        --exclude=/sys          \
 +
        /                      \
 +
        mypc.example.com:/home/archive/mytablet/
-
gconftool -R /system/osso/connectivity/IAP > /root/wifi-list.txt
+
Change "mypc.example.com" to the IP/hostname of your computer and the target directory to whatever suits you. Don't forget to make the script executable and it must be run as root of course.
-
rsync  -avz                    \
+
The "dpkg -l" command makes a list of installed packages and gconftool-2 lists all internet access points (Wi-Fi and GPRS), so you can copypaste details back later.
-
        --exclude=/dev          \
+
-
        --exclude=/media        \
+
-
        --exclude=/mnt/initfs  \
+
-
        --exclude=/proc        \
+
-
        --exclude=/sys          \
+
-
        /                      \
+
-
        mypc.example.com:/home/archive/mytablet/
+
-
</pre>
+
-
==Wiping Clean==
+
==Automatic/periodic/scheduled backups==
-
Wiping your table clean is achieved by reflashing. If you upgraded to your current version of maemo rather than flashing the latest version, you'll get a small performance boost by doing this. Flash according to [[Updating_the_tablet_firmware]].
+
Maemo currently does not provide an option to schedule backups nor does the osso-backup have interface to be run from command line and thus be scheduled. So the backup scripts needs to be written manually. You get them here (or you write your own), but to schedule them periodically you need fcron or similar. The scheduling part is covered in detail on [[fcron]] wiki page. With combining these two wiki pages you can have fully working automatic backups.
 +
==Wipe methods==
-
==Restoring==
+
Wiping the device clean is achieved with reflashing. This is covered in [[Updating_the_tablet_firmware]] wiki page and similar.
-
Backing up and reflashing were the easy parts, restoring takes a bit longer, and is a bit more tedious. This is where you should only restore things that were definitely properly working before you started, restoring broken configuration files is a bad idea!
+
==Restore methods==
-
As well as reinstalling all the applications you want, you'll need to install (dropbear) ssh & sshd in order to copy the files back on. Be sure to set a password for user "user" and also probably root!
+
Restoring is the hardest part in this process and you need to have a little knowledge about your system, otherwise backup and restore rather with osso-backup. It is a good choice to perform a full backup after a successful setup/reflash/restore.
-
You might like to do a total backup of your tablet immediately after restoring all the applications in order to have a baseline comparison.
+
Restoring entries below were made by the author of the rsync backup script, but they are very similar to any restoring process. Also don't forget that the applications which use the files you are restoring need to be closed/stopped/killed.
-
BTW, be sure not to be running the application which uses the files being restored!
+
===Contacts===
 +
You need to create a dummy entry before restoring contacts. Run the contacts application first and create a contact, anything will do. Then exit the contacts application and restore the files in '''/home/user/.osso-abook/db''' and '''/home/user/.osso-abook-backup/db'''.
===Bookmarks===
===Bookmarks===
-
Bookmarks are easy.
+
Close the browser first, then simply copy the files from your archive to the phone to '''/home/user/.bookmarks'''. The bookmarks should appear immediately.
-
Close the browser first, then simply copy them from your archive to the tablet thus:
+
The bookmarks are saved in '''MyBookmarks.xml''' file, so this is the one that you really need, other files are thumbnails and the like.
-
<pre>
+
-
cd /home/archive/mytablet/home/user/.bookmarks
+
-
scp -pr * user@mytablet.example.com:/home/user/.bookmarks
+
-
</pre>
+
-
The bookmarks should appear straight away, either in the browser or in the home screen short-cut.
+
===Calendar===
 +
The calendar entries are in the file '''/home/user/.calendar/calendardb'''.
-
===IM/Chat and SIP Accounts===
+
===Repository and packages list===
-
The various jabber and SIP accounts are stored in var/lib/gconf/apps/telepathy/mc/accounts. It's probably a good idea to set your presence to "off" before trying to restore, which you do as follows:
+
These are located in '''/var/lib/hildon-application-manager''', files '''catalogues.backup''', '''catalogues2.backup''' and '''packages.backup'''. These can't be just copied back, because osso-backup uses them in its own way (asks which applications should be reinstalled), but you can use them as list of what you had installed.
-
<pre>
+
===IM/Chat/SIP accounts===
-
cd /home/archive/mytablet/var/lib/gconf/apps/telepathy/mc/accounts
+
-
scp -pr * user@mytablet.example.com:/var/lib/gconf/apps/telepathy/mc/accounts
+
-
</pre>
+
-
===Contacts===
+
These accounts are stored in /var/lib/gconf/apps/telepathy/mc/accounts. It's probably a good idea to set your presence to "off" before trying to restore.
-
Contacts are stored in /home/user/.osso-abook, however, you need to create a dummy entry BEFORE restoring the files.
+
===E-mail (Modest)===
-
So, run the accounts application and create a contact, any old rubbish will do.
+
Restoring /home/users/.modest and /var/lib/gconf/apps/modest doesn't work properly. I had to create the email server settings, but at least the old email did come back. Actually, I think it might have worked, but the mailbox didn't appear. I discovered that the old mailboxes were there when I looked for them in Menu->View and chose one of the mailboxes.
-
Then exit the contacts application and restore the files thus:
+
The rabbit hole goes deeper. I didn't notice there was a problem after restoring, as I use a special email address for my tablet and it didn't get any email for a while, so I was quite happy accessing my recovered emails. When a new email arrived, it killed modest, and I was unable to restart it - the UI would show up briefly before modest died. The only way I could make modest run without crashing was to rename /home/user/.modest to /home/user/.modest.xxx.
-
 
+
-
<pre>
+
-
cd /home/archive/mytablet/home/user/.osso-abook
+
-
scp -pr . user@mytablet:/home/user/.osso-abook
+
-
</pre>
+
-
 
+
-
 
+
-
===Email (modest)===
+
-
 
+
-
I'm stuck on this one. Restoring /home/users/.modest and /var/lib/gconf/apps/modest didn't work properly; I had to create the email server settings, but at least the old email did come back.
+
-
 
+
-
Actually. I think it might have worked, but the mailbox didn't appear. I discovered that the old mailboxes were there when I looked for them in Menu->View and chose one of the mailboxes.
+
-
 
+
-
Maybe someone can confirm this by PM'ing me at http://talk.maemo.org/member.php?u=5686
+
-
 
+
-
The rabbit hole goes deeper. I didn't notice there was a problem after restoring, as I use a special email address for my tablet and it didn't get any email for a while, so I was quite happy accessing my recovered emails. When a new email arrived, it killed modest, and I was unable to restart it - the UI would show up briefly before modest died. The only way I could make modest run without crashing was to rename /home/user/.modest to /home/user/.modest.xxx
+
-
 
+
-
This inability to backup and restore modest strikes me as a major problem and that modest should therefore not be trusted for pop3 email where you retrieve and delete emails off the server, if any email addresses are vitally important and losing them would be a disaster!
+
===gPodder===
===gPodder===
-
Close gpodder. Copy the gpodder config directory back thus:
+
Close gPodder and copy its config directory to /home/user/.config/gpodder.
-
<pre>
+
===OpenVPN Applet===
-
cd /home/archive/mytablet/home/user/.config/gpodder
+
-
scp -pr * user@mytablet.example.com:/home/user/.config/gpodder
+
-
</pre>
+
-
 
+
-
Since gpodder keeps the downloaded podcast audio files on a flash memory card, they should be available immediately.
+
-
 
+
-
===OpenVPN===
+
-
 
+
-
It might seem obvious, but if you used the openvpn applet and imported configurations, you might not know the configuration files live in /etc/openvpn
+
-
 
+
-
When you copy them over, be sure to have them owned by user root, group root, and protection u=rw,go=
+
-
 
+
-
Also, don't trample over the maemo-update-resolvconf script, keep the one that came with the fresh flash install; it probably won't matter as I don't think it's changed much if ever, but best to stick to the package maintainer's version.
+
 +
If you use the OpenVPN Applet the configuration files are stored in /etc/openvpn. After you copy them be sure to have them owned by user "root", group "root", and protected so that user (root) has rw privileges, and no one else has anything.
===RSS Feeds===
===RSS Feeds===
-
The RSS feeds are stored as a bunch of files, very easy to restore.
+
Close RSS application and copy files to /home/user/.osso_rss_feed_reader.
-
 
+
-
Close rss reader. Copy the files back thus:
+
-
 
+
-
<pre>
+
-
cd /home/archive/mytablet/home/user/.osso_rss_feed_reader
+
-
scp -pr * user@mytablet.example.com:/home/user/.osso_rss_feed_reader
+
-
</pre>
+
-
 
+
-
When RSS reader is started, everything should be back the way it was before.
+
-
 
+
-
===wifi access points===
+
-
 
+
-
Although you'll have to manually re-enter the wifi access points, it's easier when you don't have to tediously type in WPA pass phrases as you can copy/paste then from the file created during the backup. Restore this file:
+
-
 
+
-
<pre>
+
-
cd /home/archive/mytablet/root
+
-
scp -pr wifi-list.txt root@mytablet.example.com:
+
-
</pre>
+
-
 
+
-
Then view this file in a shell (install xterm, run it, "sudo becomeroot", "more wifi-list.txt" whilst setting up access to a wireless AP.
+
-
 
+
-
 
+
-
== Stability of end result ==
+
-
 
+
-
I wish I could say that Ihad no problems after following any of these processes. However, perhaps it was a fluke, but all my accounts mysteriously disappeared one day, after the tablet had been working just fine for a couple of weeks; luckily I was able to restore my SIP and GTalk accounts in a few minutes from backup!
+
 +
===Wi-Fi and GPRS access points===
 +
You'll have to manually re-enter them, but you can copypaste details from the file created with rsync backup script (iap.txt).
[[Category:Power users]]
[[Category:Power users]]

Revision as of 18:57, 27 March 2010

There are several scenarios where you might want to manually backup and restore your phone. Using manual methods (as opposed to using osso-backup) is convenient for advanced users (to have more control over their phone), scheduling backups with fcron and the like, starting from scratch (if you want to wipe the phone and restore file-by-file) - because osso-backup can backup also problematic files.

This was discussed at talk.maemo.org.

Contents

Backup methods

Copying

This script backs up contacts, conversations, calendar, bookmarks, repository and packages list to external memory card's directory Backup which then contains subdirectories named with date and time when the backup was performed. For example: "Memory_card/Backup/2010-03-03 00-00". It also displays notification during backup, because it was made to be used with fcron.

#!/bin/sh
run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Making backup..."
date=`date +"%F %H-%M"`
mkdir -p /media/mmc1/Backup/"$date"/home/user/.bookmarks
mkdir /media/mmc1/Backup/"$date"/home/user/.calendar
mkdir /media/mmc1/Backup/"$date"/home/user/.osso-abook
mkdir /media/mmc1/Backup/"$date"/home/user/.osso-abook-backup
mkdir -p /media/mmc1/Backup/"$date"/var/lib/hildon-application-manager
cp /home/user/.bookmarks/MyBookmarks.xml* /media/mmc1/Backup/"$date"/home/user/.bookmarks
cp /home/user/.calendar/calendardb /media/mmc1/Backup/"$date"/home/user/.calendar
cp -r /home/user/.osso-abook/db /media/mmc1/Backup/"$date"/home/user/.osso-abook
cp -r /home/user/.osso-abook-backup/db /media/mmc1/Backup/"$date"/home/user/.osso-abook-backup
cp -r /home/user/.rtcom-eventlogger /media/mmc1/Backup/"$date"/home/user
cp /var/lib/hildon-application-manager/catalogues* /media/mmc1/Backup/"$date"/var/lib/hildon-application-manager
cp /var/lib/hildon-application-manager/packages.backup /media/mmc1/Backup/"$date"/var/lib/hildon-application-manager
run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Backup created"

osso-backup (what is backed up by it)

osso-backup is the default Backup application on the phone. You can use it for "manual" backup, because it produces standard .zip compressed files which can be opened on any system. The list of files that osso-backup backs up can be obtained by making a backup with it and opening these zip files (the list is too long for this wiki page).

rsync

rsync is standard Linux/Unix file and directory synchronization tool. It is in extras repository. An example backup script is shown here:

#!/bin/sh

dpkg -l > /root/dpkg.txt

gconftool-2 -R /system/osso/connectivity/IAP > /root/iap.txt

rsync   -avz                    \
        --exclude=/dev          \
        --exclude=/media        \
        --exclude=/mnt/initfs   \
        --exclude=/proc         \
        --exclude=/sys          \
        /                       \
        mypc.example.com:/home/archive/mytablet/

Change "mypc.example.com" to the IP/hostname of your computer and the target directory to whatever suits you. Don't forget to make the script executable and it must be run as root of course.

The "dpkg -l" command makes a list of installed packages and gconftool-2 lists all internet access points (Wi-Fi and GPRS), so you can copypaste details back later.

Automatic/periodic/scheduled backups

Maemo currently does not provide an option to schedule backups nor does the osso-backup have interface to be run from command line and thus be scheduled. So the backup scripts needs to be written manually. You get them here (or you write your own), but to schedule them periodically you need fcron or similar. The scheduling part is covered in detail on fcron wiki page. With combining these two wiki pages you can have fully working automatic backups.

Wipe methods

Wiping the device clean is achieved with reflashing. This is covered in Updating_the_tablet_firmware wiki page and similar.

Restore methods

Restoring is the hardest part in this process and you need to have a little knowledge about your system, otherwise backup and restore rather with osso-backup. It is a good choice to perform a full backup after a successful setup/reflash/restore.

Restoring entries below were made by the author of the rsync backup script, but they are very similar to any restoring process. Also don't forget that the applications which use the files you are restoring need to be closed/stopped/killed.

Contacts

You need to create a dummy entry before restoring contacts. Run the contacts application first and create a contact, anything will do. Then exit the contacts application and restore the files in /home/user/.osso-abook/db and /home/user/.osso-abook-backup/db.

Bookmarks

Close the browser first, then simply copy the files from your archive to the phone to /home/user/.bookmarks. The bookmarks should appear immediately.

The bookmarks are saved in MyBookmarks.xml file, so this is the one that you really need, other files are thumbnails and the like.

Calendar

The calendar entries are in the file /home/user/.calendar/calendardb.

Repository and packages list

These are located in /var/lib/hildon-application-manager, files catalogues.backup, catalogues2.backup and packages.backup. These can't be just copied back, because osso-backup uses them in its own way (asks which applications should be reinstalled), but you can use them as list of what you had installed.

IM/Chat/SIP accounts

These accounts are stored in /var/lib/gconf/apps/telepathy/mc/accounts. It's probably a good idea to set your presence to "off" before trying to restore.

E-mail (Modest)

Restoring /home/users/.modest and /var/lib/gconf/apps/modest doesn't work properly. I had to create the email server settings, but at least the old email did come back. Actually, I think it might have worked, but the mailbox didn't appear. I discovered that the old mailboxes were there when I looked for them in Menu->View and chose one of the mailboxes.

The rabbit hole goes deeper. I didn't notice there was a problem after restoring, as I use a special email address for my tablet and it didn't get any email for a while, so I was quite happy accessing my recovered emails. When a new email arrived, it killed modest, and I was unable to restart it - the UI would show up briefly before modest died. The only way I could make modest run without crashing was to rename /home/user/.modest to /home/user/.modest.xxx.

gPodder

Close gPodder and copy its config directory to /home/user/.config/gpodder.

OpenVPN Applet

If you use the OpenVPN Applet the configuration files are stored in /etc/openvpn. After you copy them be sure to have them owned by user "root", group "root", and protected so that user (root) has rw privileges, and no one else has anything.

RSS Feeds

Close RSS application and copy files to /home/user/.osso_rss_feed_reader.

Wi-Fi and GPRS access points

You'll have to manually re-enter them, but you can copypaste details from the file created with rsync backup script (iap.txt).