| The Following 6 Users Say Thank You to traysh For This Useful Post: | ||
|
|
2013-07-04
, 17:12
|
|
Community Council |
Posts: 4,902 |
Thanked: 12,827 times |
Joined on May 2012
@ Southerrn Finland
|
#2
|
| The Following User Says Thank You to juiceme For This Useful Post: | ||
|
|
2013-07-04
, 17:16
|
|
Posts: 324 |
Thanked: 739 times |
Joined on Jun 2009
@ São Paulo, Brazil
|
#3
|
Allright, now I got it, you are using host computers btrfs'es journalling to track the changes. At first I thought you had formatted your N9 partitions as btrfs.
nice, Ill have to try that.
| The Following User Says Thank You to traysh For This Useful Post: | ||
|
|
2013-07-05
, 20:32
|
|
Community Council |
Posts: 4,902 |
Thanked: 12,827 times |
Joined on May 2012
@ Southerrn Finland
|
#4
|
|
|
2013-07-05
, 20:45
|
|
Posts: 324 |
Thanked: 739 times |
Joined on Jun 2009
@ São Paulo, Brazil
|
#5
|
Should be possible, and not too difficult to port as it has already been introduced on 2.6.32. Altough, I cannot say how effective it is running on flash SF.
| The Following User Says Thank You to traysh For This Useful Post: | ||
|
|
2013-07-05
, 20:48
|
|
Posts: 324 |
Thanked: 739 times |
Joined on Jun 2009
@ São Paulo, Brazil
|
#6
|
| The Following User Says Thank You to traysh For This Useful Post: | ||
|
|
2013-07-07
, 22:59
|
|
Community Council |
Posts: 4,902 |
Thanked: 12,827 times |
Joined on May 2012
@ Southerrn Finland
|
#7
|
But btrfs has been in huge development, do you really think it wouldn't be difficult to backport?
The advantage of this method over dd is it will not use the partition size of disk space for each backup. In the first backup, all files in each partition will be copied (and not the unused space as in dd). In the next backups, only the differences will be copied. Yet, you will have multiple btrfs subvolume snapshots with all the files but not multiple copies of the files due to this filesystem CoW capability.
real example:
One additional advantage is that the backups are fast because only the differences are transferred between the phone and the computer.
Example of the script output:
#!/bin/bash # # Script for creating backups of all the N9's default partitions. # Author: Danilo Luvizotto # Date: 20130704 # License: GPLv2 # No warranty! I'm not responsible for any damage. Please read the license for more information on that. set -e ## Please adjust these variables MyDocs_PART=/dev/disk/by-uuid/4F43-B7CB #MyDocs partition. For me, /dev/sdb1 would also work. rootfs_PART=/dev/disk/by-uuid/1707b697-1350-4dd1-a111-56945171c7bd #rootfs partition. For me, /dev/sdb2 would also work. home_PART=/dev/disk/by-uuid/e035cb56-b983-477d-93f1-7da10896fd98 #home partition. For me, /dev/sdb3 would also work. MOUNTPOINT=/mnt ##End of the adjusting section #The script should be run as root if [[ "$(whoami)" != "root" ]] then echo "ERROR: This script must be run as root!" echo "" exit 1 fi hash btrfs >/dev/null 2>&1 || { echo >&2 "This script requires your filesystem was formatted as btrfs. Exiting."; exit 1; } hash rsync >/dev/null 2>&1 || { echo >&2 "This script requires rsync. Exiting."; exit 1; } echo "This script creates incremental backups of the N9's partitions as btrfs snapshots. If your filesystem is not btrfs, this will fail." echo "In case of any error, please verify if any partitions were left mounted." echo "Press ENTER to continue." read function find_unused_filename { i=1 OUTPUT="_$(date '+%Y%m%d')" while [[ -a MyDocs"$OUTPUT" || -a rootfs"$OUTPUT" || -a home"$OUTPUT" ]] do i=$(( $i + 1 )) OUTPUT="_$(date '+%Y%m%d')_$i" done } mkdir -p $MOUNTPOINT if [[ -n "$(mount | grep $MOUNTPOINT)" ]] then echo "ERROR: something is already mounted in $MOUNTPOINT!" echo "Unmount it and try again." echo "" exit 1 fi # 0 - Find an unused filename find_unused_filename # 1 - Backup MyDocs OBJ=MyDocs mount $MyDocs_PART $MOUNTPOINT if [[ ! -a "$OBJ"_last ]] then btrfs subvolume create "$OBJ"_last fi rsync -av --delete $MOUNTPOINT/ "$OBJ"_last/ btrfs subvolume snapshot "$OBJ"_last $OBJ$OUTPUT umount $MOUNTPOINT # 2 - Backup rootfs OBJ=rootfs mount $rootfs_PART $MOUNTPOINT if [[ ! -a "$OBJ"_last ]] then btrfs subvolume create "$OBJ"_last fi rsync -av --delete $MOUNTPOINT/ "$OBJ"_last/ btrfs subvolume snapshot "$OBJ"_last $OBJ$OUTPUT umount $MOUNTPOINT # 3 - Backup home OBJ=home mount $home_PART $MOUNTPOINT if [[ ! -a "$OBJ"_last ]] then btrfs subvolume create "$OBJ"_last fi rsync -av --delete $MOUNTPOINT/ "$OBJ"_last/ btrfs subvolume snapshot "$OBJ"_last $OBJ$OUTPUT umount $MOUNTPOINT echo "" echo "Backups created:" echo "1) MyDocs$OUTPUT" echo "2) rootfs$OUTPUT" echo "3) home$OUTPUT"#!/bin/bash # # Script for restoring backups of all the N9's default partitions. # Author: Danilo Luvizotto # Date: 20130705 # License: GPLv2 # No warranty! I'm not responsible for any damage. Please read the license for more information on that. set -e ## Please adjust these variables MyDocs_PART=/dev/disk/by-uuid/4F43-B7CB #MyDocs partition. For me, /dev/sdb1 would also work. rootfs_PART=/dev/disk/by-uuid/1707b697-1350-4dd1-a111-56945171c7bd #rootfs partition. For me, /dev/sdb2 would also work. home_PART=/dev/disk/by-uuid/e035cb56-b983-477d-93f1-7da10896fd98 #home partition. For me, /dev/sdb3 would also work. MOUNTPOINT=/mnt ##End of the adjusting section #The script should be run as root if [[ "$(whoami)" != "root" ]] then echo "ERROR: This script must be run as root!" echo "" exit 1 fi hash rsync >/dev/null 2>&1 || { echo >&2 "This script requires rsync. Exiting."; exit 1; } echo "This restores backups of the N9's partitions to the device." echo "In case of any error, please verify if any partitions were left mounted." echo "Enter 'I have just made a backup!' and press ENTER to continue." read -r USERINPUT if [[ "$USERINPUT" != "I have just made a backup!" ]] then echo "You entered '$USERINPUT', thus choosed not to restore the backup". exit 0 else echo "" echo "...and I hope you really did..." echo "" fi if [[ -z "$1" ]] then echo "Usage: $0 <backup date>[_#]" exit 1 fi INPUT=_"$1" ##Verify if the required backup files exist if [[ ! -a MyDocs"$INPUT" ]] then echo "The file MyDocs$INPUT does not exist." echo "Can't restore backup, exiting!" echo "" exit 1 fi if [[ ! -a rootfs"$INPUT" ]] then echo "The file rootfs$INPUT does not exist." echo "Can't restore backup, exiting!" echo "" exit 1 fi if [[ ! -a home"$INPUT" ]] then echo "The file home$INPUT does not exist." echo "Can't restore backup, exiting!" echo "" exit 1 fi mkdir -p $MOUNTPOINT if [[ -n "$(mount | grep $MOUNTPOINT)" ]] then echo "ERROR: something is already mounted in $MOUNTPOINT!" echo "Unmount it and try again." echo "" exit 1 fi # 1 - Restore MyDocs OBJ=MyDocs mount $MyDocs_PART $MOUNTPOINT rsync -av --delete "$OBJ$INPUT"/ $MOUNTPOINT/ umount $MOUNTPOINT # 2 - Backup rootfs OBJ=rootfs mount $rootfs_PART $MOUNTPOINT rsync -av --delete "$OBJ$INPUT"/ $MOUNTPOINT/ umount $MOUNTPOINT # 3 - Backup home OBJ=home mount $home_PART $MOUNTPOINT rsync -av --delete "$OBJ$INPUT"/ $MOUNTPOINT/ umount $MOUNTPOINT echo "" echo "Backups restored:" echo "1) MyDocs$INPUT" echo "2) rootfs$INPUT" echo "3) home$INPUT"1) The filesystem in the computer in which the backup will be made must be btrfs. No ext2, ext3, ext4 or anything else.
2) Rsync must be installed in the system
3) It is required familiarity with exposing the phone's partitions to a computer using this method.
I know this is too advanced to most of this forum users, but I hope it will be useful to someone.
Last edited by traysh; 2013-07-05 at 20:51. Reason: Added the restore script