The Following 6 Users Say Thank You to GameboyRMH For This Useful Post: | ||
|
2010-07-28
, 16:03
|
Posts: 992 |
Thanked: 738 times |
Joined on Jun 2010
@ Low Earth Orbit
|
#2
|
... and go watch a movie or something ...
|
2010-08-19
, 01:31
|
Posts: 18 |
Thanked: 2 times |
Joined on Nov 2009
|
#3
|
|
2010-08-19
, 22:07
|
Posts: 21 |
Thanked: 8 times |
Joined on Jun 2010
@ North America, west coast
|
#4
|
The Following User Says Thank You to kwtm For This Useful Post: | ||
|
2010-08-19
, 22:19
|
Posts: 346 |
Thanked: 271 times |
Joined on Jan 2010
|
#5
|
|
2010-08-19
, 22:28
|
Posts: 692 |
Thanked: 264 times |
Joined on Dec 2009
|
#6
|
Good tutorial but I think that restore data to a running system is a bad idea.
|
2010-08-19
, 22:29
|
Posts: 31 |
Thanked: 35 times |
Joined on Jun 2010
|
#7
|
Code:#! /bin/sh stty -echo; ssh backupuser@192.168.254.100 "sudo -v"; stty echo rsync -avzn --delete \ #Change "-avzn" to "-avz" after testing --rsync-path "sudo rsync" \ --exclude /proc/'*' \ --exclude /sys/'*' \ --exclude /syspart/'*' \ --exclude /dev/'*' \ --exclude /tmp/'*' \ --exclude /var/tmp/'*' \ --exclude /.debian/'*' \ #Excludes your debian chroot if you have one - recommended --exclude /media/'*' \ #Excludes /media - remove this line to back up the microsd contents as well / backupuser@192.168.254.100:/media/disk1/n900bak
The Following 2 Users Say Thank You to wotevah For This Useful Post: | ||
|
2010-08-19
, 22:57
|
|
Posts: 1,062 |
Thanked: 961 times |
Joined on May 2010
@ Boston, MA
|
#8
|
Great tutorial. I use Grsync to do the same.
Does any one know of a good way to schedule a backup regularly?
|
2010-08-20
, 06:29
|
Posts: 21 |
Thanked: 8 times |
Joined on Jun 2010
@ North America, west coast
|
#9
|
Make sure the filesystem you are copying TO is capable of storing all the metadata and permissions. For example, backing up to VFAT is not ideal (not only that but VFAT truncates file times to even number of seconds so it'll always need resyncing).
The Following User Says Thank You to kwtm For This Useful Post: | ||
|
2010-12-05
, 09:39
|
Posts: 16 |
Thanked: 13 times |
Joined on Jan 2009
@ Sofia, Bulgaria
|
#10
|
Tags |
backup, howto, rsync |
|
So a quick overview of what you need:
- An N900 (although this can be adapted for any Linux-based machine) with rootsh (duh), rsync and openssh (ssh client) installed. You can't get rsync through the Application Manager GUI, run "apt-get install rsync" as root.
- A Linux-based PC with sshd (SSH server) and rsync installed. You must be able to log in to this PC as a user that has sudo privileges.
Now I'm going to warn you a bit, rsync is one of the most potentially dangerous applications in Linux if not used carefully, right up there with dd and rm -rf. YOU CAN WIPE OUT TONS OF DATA IF YOU MAKE A MISTAKE SO BE CAREFUL. Pass an -n argument to rsync to do a "dry run" where no data is changed before doing any real tests.
Now make the following shellscript on your N900. Be sure to run it as root (I chown'd and chgrp'd mine to root, and set the permissions to 744) or the backup won't work properly.
In my example, I'm backing up to the PC at 192.168.254.100 as the user backupuser. I'm copying the root of my N900's filesystem (/) to /media/disk1/n900bak/ on the remote PC.
Once you're satisfied that it looks like it's working, change "-avn" to "-av" on the second line to do it for real. Your first backup could take a LONG time, mine took about 2 hours over a b/g wifi network, and I don't have a whole lot of data on my N900. The N900 got pretty hot too as it's processing flat out. So plug it in, open the keyboard, set it on it's kickstand (this will keep it cool and keep the battery from draining) and go watch a movie or something.
Once the first backup is complete (it should finish without errors), you can run the script again to bring your backup up to date. It will be MUCH faster, probably just a few minutes.
Now say your N900 fell in a sewer drain and you bought a new one. First bring it back up to the same firmware version you used to have, to make sure all component firmware versions are the same. Next, to restore your data, install rootsh+openssh+rsync, make a copy of your script, and reverse the arguments on the last line (be careful to include a trailing slash on the source directory this time). In my example that would be:
Run the modified script as root and wait. When it's finished, reboot your phone and everything that was backed up should be restored. Be aware that with the --delete argument, any data on the N900 that isn't in the backup will be deleted.
Note: On some recent distros you may have to add a "defaults visiblepw" option to your /etc/sudoers (using visudo) on the server for this to work - this setting allows situations where passwords being entered could potentially be visible in the terminal, but this script is made to prevent this from happening anyways.
"Impossible is not in the Maemo vocabulary" - Caballero
Last edited by GameboyRMH; 2011-01-02 at 15:49. Reason: After testing, I no longer recommend compression. Also prevent redundant backup of /opt/, /var/run/, and add note about visiblepw