[Howto] Odroid-Backup tool - backup and restore tool

Moderators: odroid, meveric, mdrjr

[Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Wed Aug 03, 2016 3:54 pm

You've worked hard to get your system in shape, worked out all of the bugs but you know that things are not going to last and you may be an update away from a broken Chromium or you might want to experiment with a new kernel or experimental package... To save yourself from future pain it's always a good idea to make a backup! However, backups are usually a source of confusion on the forum - lots of new users struggle with them. In this how-to we'll learn what needs to be done to keep your system safe. This has been previously discussed here as well (http://forum.odroid.com/viewtopic.php?f=112&t=18715)

Disks, partitions and file systems

Seasoned computer users have no problem distinguishing between disks, partitions and filesystems, but let's analyze them to have a common starting point. A disk is generally a physical device that stores data into randomly-accessible blocks. In more complex setups multiple physical disks can be combined as RAID arrays (either hardware or software) and exposed to the operating system as virtual disks. Partitions are sections on disks that usually hold a filesystem. Filesystems manage how files and data are stored in order to be found later on. In order to make a backup of your Odroid system you will need to preserve the partition information and the contents of the partitions.

Image
Figure 1. Partition layout of an Odroid C1 tripleboot image

All disks start off with a 512 byte block of data that typically holds the bootloader (for x86 systems, 446 bytes) and the Master Boot Record (MBR https://en.wikipedia.org/wiki/Master_boot_record, 64 bytes). The MBR is a table with the start offset, length and partition type of your 4 primary partitions. These are the partitions mapped as 1-4 in the linux kernel (e.g. sda1-sda4 for a disk called sda). The MBR is an old data structure, introduced in 1983, so it has some limitations. The need to use ever-larger disks (>2TB) lead to the introduction of the GPT (GUID Partition Table https://en.wikipedia.org/wiki/GUID_Partition_Table) which replaces the MBR in newer systems. The Odroids can use both MBR and GPT, but the boot media is designed as a MBR volume because of its relatively small size and simplicity.

But, as you can see in figure 1, a disk may have more than 4 partitions. This is achieved by using a trick - one primary partition is marked as "extended" and it can contain any number of logical partitions (linux represents them with numbers from 5 onwards - e.g. sda5, sda6). The partition information for the logical partitions is stored in structures similar to the MBR called Extended Boot Record (EBR https://en.wikipedia.org/wiki/Extended_boot_record) which looks like a linked list (figure 2), but preceeds the actual partition on disk.


Image
Figure 2. EBR position on disk

The partitions you'll usually see on Odroids are FAT16/FAT32 (seen as vfat under the mount command) and ext2/3/4. There are other partition types supported by Linux (e.g. NTFS, XFS, ZFS), but they are usually not critical to the boot process so they will be out of our scope. There are backup tools such as BackupPC (https://www.howtoforge.com/linux_backuppc) or Clonezilla (http://clonezilla.org/) which support more partition types or do backup on file level. These same tools should be used to backup your personal data, such as files, pictures or music. It's also a good idea before starting a backup to do a little "spring cleaning" and delete things you no longer need such as temporary files or downloads, to reduce the time it takes to do the backup and the size of the backup file. For instance, you can delete the cache of downloaded packages via apt with:

Code: Select all
$ sudo apt-get clean


Backup strategies

There are a few ways of making a backup of your EMMC/SD card. The simplest to implement is to make a 1:1 binary copy of your data to an image file. For this task you can use a tool such as dd or Win32diskImager. Note that all the commands that follow expect to have the variable $backupDir replaced by the path to your desired backup directory (which can't be on the same partition you're trying to backup for obvious reasons).

Code: Select all
$ sudo dd if=/dev/mmcblk0 of=$backupDir/backup.img bs=1M


In the command above "if" represents "input file" and should point to the block device representing your disk (e.g. /dev/mmcblk0) and "of" represents "output file" - where data should be written to. The parameter "bs" represents "block size" - how much data is read and written at once. A variation of the dd command that shows progress uses the "pv" command (pipe viewer):

Code: Select all
# apt-get install pv
# dd if=/dev/mmcblk0 bs=1M | pv | dd of=$backupDir/backup.img


Restoring the data is equally easy - just replace the values of "if" and "of":
Code: Select all
$ sudo dd if=$backupDir/backup.img of=/dev/mmcblk0 bs=1M


Note that dd makes a binary copy of your disk. This means that it will copy also the free space on your disk. The default output file will be as large as your disk, which means that copying a 64GB SD card of mostly empty space will take a long time and take up a lot of space. The advantage is that you can later run tools like photorec (http://www.cgsecurity.org/wiki/PhotoRec) on the free space and possibly recover deleted files - which is useful when doing data forensics or recovering from a bad media. The disadvantage is that the image will be big and slow to copy. You can use dd together with gzip to shrink the image before writing it to reduce size a bit, but you won't gain time:
Code: Select all
# dd if=/dev/mmcblk0 bs=1M | gzip -c > $backupDir/backup.img.gz
# gunzip -c $backupDir/backup.img.gz | dd of=/dev/mmcblk0 bs=1M


Also note that in theory you can do a backup with dd on a live system (copy it while the partitions are mounted), but there is a risk of inconsistencies if files are changed while doing the backup. It's best to do an offline backup (pull the eMMC/SD card, plug it into a different system and do the backup without having mounted partitions). There's also a disadvantage when copying between media of slightly different sizes (not all 16GB cards are exactly the same size) - you might end up with a truncated partition on your destination.

"dd" has the advantage that it is easy to use, but to gain backup/restore speed and minimize necessary backup space you need to break up the backup operation into several steps and avoid backing up free space. For this you'll need to backup:
  • MBR + EBR
  • Bootloader
  • Individual partitions
You can still cheat and use dd if you use gparted to shrink your largest/last partition to only the used size, dd up to that point and resize the partition back to the original size after you restore it, but it involves some manual work.

MBR backup and restore
The MBR and EBR are small data structures and can be easily backed up with dd. But because the EBR's position on disk can vary you should rely on a partitioning tool to extract and restore the MBR/EBR data. Such a tool is sfdisk

Code: Select all
$ sudo apt-get install sfdisk
$ sudo sfdisk -d /dev/mmcblk0 > $backupDir/partition_table.txt


To restore it later you need to supply the saved file to sfdisk like this:

Code: Select all
$ sudo sfdisk /dev/mmcblk0 < $backupDir/partition_table.txt


Note that overwriting the MBR on a disk with existing partitions is equivalent to deleting the partitions since the operating system will not be able to find the offsets to the old partitions anymore, so use the restore step with extreme care! This backup you can do on a live system without risks (since partition tables are not usually changed during runtime).

Bootloader backup and restore
Odroids use U-Boot as a bootloader (detailed in Odroid Magazine November 2015: http://magazine.odroid.com/wp-content/u ... pdf#page=6). U-Boot stores its code and data in the unallocated space after the MBR and the beginning of the first partition. There is also some bootstrap code in the first 446 bytes in the first sector (before the partition table). Since the size and structure of U-Boot may differ between Odroid boards, it's safest to do a binary backup of this unallocated space with dd. First you need to find out the start sector of the first partition with sfdisk:

Code: Select all
$ sudo sfdisk -l /dev/mmcblk0


Image
Figure 3. Identify the start sector of the first partition with sfdisk and sector size.

As you can see in figure 3, the first partition (loop0p1) starts at offset 49152. So, we'll need to copy everything up to and including sector 49151. The bs (block size) parameter must match what sfdisk reported in the "Units" line:

Code: Select all
$ sudo dd if=/dev/mmcblk0 of=$backupDir/bootloader.bin bs=512 count=49151


Note that the dd command will also copy over the MBR (which is sector 0). To restore the bootloader (and skip restoring the partition table as well), you can do:

Code: Select all
$ sudo dd if=$backupDir/bootloader.bin of=/dev/mmcblk0 bs=512 skip=1 seek=1


You should also restore the bootstrap code from the first sector - you can do so with:
Code: Select all
$ sudo dd if=$backupDir/bootloader.bin of=/dev/mmcblk0 bs=446 count=1


To restore the partition table as well, do not add the skip and seek parameters. This too can be done on a live system since the data is mostly read-only.

FAT partitions backup and restore
By default HardKernel's images come with a FAT16/32 partition mounted under /media/boot that holds the kernel, initrd, device tree and boot.ini files. All of these are crucial during system startup. Android installs expose this partition as "sdcard" storage.

There are several tools for linux that backup FAT partitions. I used to use partimage, but it fails to verify the checksum of the partitions on C2, so I switched to partclone. Partclone can do a block backup of FAT partitions preserving data at the same offsets, but can skip empty space.

Code: Select all
$ sudo apt-get install partclone
$ sudo partclone.vfat -c -s /dev/mmcblk0p1 -O $backupDir/partition_1.img


The "-c" specifies "clone", "-s" is the source partition (in our case the first partition) and "-O" is the output file (which will get overwritten if it exists). Note that partclone cannot operate on mounted filesystems and will exit with an error. In order to back up from a running odroid you will need to unmount /media/boot, perform the backup and mount it back again.

To restore a FAT partition you can run this command:

Code: Select all
$ sudo partclone.restore -s $backupDir/partition_1.img -o /dev/mmcblk0p1


Image
Figure 4. Partclone backup with prior unmounting of /media/boot

Unfortunately, partclone will not allow you to restore a partition to a smaller or larger target partition - so any size adjustment you will need to make after the restore is done. Actually you can restore on a larger partition, but you will need to manually grow it to use the extra space later on.

Ext2/3/4 partitions backup and restore

In order to backup and restore Ext2/3/4 filesystems we'll need to use a different tool called fsarchiver. Unlike partclone, fsarchiver creates backup at file level and reconstructs the filesystem upon restore. Unfortunately because of certain particularities of FAT systems where Windows boot files need to be at specific offsets the author of fsarchiver does not support backing up FAT filesystems as well - so we're stuck to using two tools for the job. But with the help of external packages fsarchiver can support other filesystems as well - such as XFS, ReiserFS, JFS, BTRFS and NTFS. It usually backs up unmounted filesystems, but can be used on live filesystems as well with the "-A" flag (may not always work). Fsarchiver has the advantage that it can restore a filesystem in a bigger or smaller target partition preserving UUIDs. In order to back up the second partition you can run the following commands:

Code: Select all
$ sudo apt-get install fsarchiver
$ sudo fsarchiver -o -v -A -j 4 savefs $backupDir/partition_2.fsa /dev/mmcblk0p2


The "-o" flag means overwrite the destination file if it exists, "-v" is verbose output, "-A" allows you to backup a mounted partition and "-j 4" allows it to use 4 cores for compression.

In order to restore a fsa backup you can run this command:
Code: Select all
$ sudo fsarchiver restfs $backupDir/partition_2.fsa id=0,dest=/dev/mmcblk0p2


Note that since fsarchiver supports multiple partitions inside an archive, it needs you to specify which partition id to restore. In our example we store only one partition in an archive, so you'll always specify id=0 when restoring.

SPI Flash

Newer boards, like the development Odroid N1 may feature a low capacity SPI NAND Flash chip designed to store the bootloader and kernel, so that it can boot from network, or from a SATA disk, without the need of a eMMC or SD card. Even if the layout of this chip hasn't been decided fully at the time of this writing, we can still back it up and restore it as a block device with dd. You can get a list (and description) of MTD devices in your Odroid by running:
Code: Select all
$ sudo cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00001000 "spi32766.0"

To back it up, you can simply use:
Code: Select all
$ sudo dd if=/dev/mtd0 of=$backupDir/flash_mtd0.bin bs=4096

In order to write to a flash device, to restore it, you need to erase the block you're going to write to. Fortunately, since we will write the whole device, we can erase it all before writing. For this we need mtd-utils which provides flash-erase:
Code: Select all
$ sudo apt-get install mtd-utils
$ sudo flash_erase -q /dev/mtd0 0 0
$ sudo dd if=$backupDir/flash_mtd0.bin of=/dev/mtd0 bs=4096


Odroid-Backup tool

Now that you know how to do things manually I can hear complaints that backup and restore should be simpler, even point and click operations. I agree - nobody has the time to remember all the command line arguments from various commands. So I hacked together a rudimentary GUI that can walk you through your backup and restore process. Hooray! :) The tool is called (wait for it!) "odroid-backup". It's written in perl because I'm too old to learn python and uses zenity and dialog to build a rudimentary GUI. To install the tool you can download it from my github:
Code: Select all
$ sudo wget -O /usr/local/bin/odroid-backup.pl https://raw.githubusercontent.com/mad-ady/odroid-backup/master/odroid-backup.pl
$ sudo chmod a+x /usr/local/bin/odroid-backup.pl


The script depends on a bunch of non-standard perl modules and some linux utilities and will display a list of missing dependencies and ways of fixing it when you first run it. To install all dependencies at once run the following:
Code: Select all
$ sudo apt-get install libui-dialog-perl zenity dialog libnumber-bytes-human-perl libjson-perl fsarchiver udev util-linux coreutils partclone parted


The script is designed to run on linux systems - either a PC to which you've hooked up a SD/eMMC through a reader, or directly on the Odroid - sorry Windows fans… Also, the script will create graphical windows if it detects you're running an X11 session, or will fall back to ncurses (display) if you're connected via ssh or terminal (you can manually force this with --text switch).

Image
Figure 5. Zenity vs display rendering

To perform a backup, start the tool in a terminal (sudo odroid-backup.pl) and select "Backup partitions", select OK (1). You will be presented with a list of removable drives in your system (you can start the program with -a to display all drives - this is the case when running directly on the Odroid, since eMMC and SD are shown as non-removable). Select the desired one and click OK (2). You will then be presented with a list of partitions on that drive. Select the ones you wish to back up (3). Next you will have to select a directory where to save the backups. It's best to have a clean directory (4). Press OK and backup will start (you have a rudimentary progress bar to keep you company) (5). When backup is done you will be presented with a status window with the backup results (and possible errors) (6). The backup files have the same naming convention used in this article. To backup a Flash NAND as well you need to re-run the tool and select it from the available disks. You can save the resulting file in the same directory as the partition backups.

Image
Figure 6. Backup steps

To perform a restore, start the tool in a terminal (sudo odroid-backup.pl) and select "Restore partitions" and select OK (1). You will have to select the directory holding your precious backups and select OK (2). In the resulting window select which partitions you wish to restore from the backup and select OK (3). Note that the partitions are restored in the same order as they were on the original disk - meaning partition 1 will be the first partition and so on. In the last window you will be asked on which drive to restore the data (4). Enjoy your time watching the progress bar progressing (5) and in the end you will have a status window with the restore results (6). The log file is also saved in /var/log/odroid-backup.log.
Image
Figure 7. Restore steps

As you might suspect no piece of software is free of bugs, but hopefully this six step script will have its uses. This script has some shortcomings - such as the zenity windows will not always display the instruction text, so I had to add it to the title bar as well, and there is no validation of the backups or restores. You will have to review the log to see that backup or restore didn't have any problems. One other limitation is that FAT partitions need to be manually unmounted before backup. Ext2/3/4 can be backed-up live. Also, the sfdisk on Ubuntu 14.04 doesn't support JSON output, so it will not work there (I can add support if needed). The program was tested backing up and restoring official HardKernel Linux and Android images, as well as tripleboot images, and so far everything seems to work. Ideas for improvement and patches are welcome as always.

Non-interactive operation
Here's how to use it in non-interactive mode. You will need to set the following parameters:
  • --backup -- to do a backup, or
  • --restore -- to do a restore. Both backup and restore are incompatible at the same time for obvious reasons
  • --disk sdc -- The disk name (without /dev) is validated and an error is printed if that name doesn't exist in your system. Valid options are shown in case you input something wrong
  • --partitions bootloader,mbr,/dev/sdc1 -- A comma separated list (with no spaces) of the partitions you want to backup or restore. Valid options are shown in case you input something wrong. When restoring, the partition names have only the number - e.g. bootloader,mbr,1,2
  • --directory -- The directory to backup to or to restore from. If it doesn't exist it will be created. Previous backups inside will be overwritten with no warning.

Example usage:
Backup
sudo odroid-backup.pl --backup --disk sdc --partitions bootloader,mbr,/dev/sdc1,/dev/sdc2 --directory backup-emmc
sudo odroid-backup.pl --backup --disk mmcblk0 --partitions bootloader,mbr,/dev/mmcblk0p1,/dev/mmcblk0p2 --directory backup-emmc

Restore
sudo odroid-backup.pl --restore --disk sdc --partitions bootloader,mbr,1,2 --directory backup-emmc
sudo odroid-backup.pl --restore --disk mmcblk0 --partitions bootloader,mbr,1,2 --directory backup-emmc

Known limitations
If you backup an emmc for XU3/4, the hidden sectors (/dev/mmcblk0boot0, /dev/mmcblk0boot1) are not backed-up/restored. These blocks contain parts of the UBoot loader. When restoring a backup on an SD card or on a new eMMC, the board might boot with an older UBoot version (stored before the first partition). As a result of this the UBoot environment might be incomplete (e.g. there is no ${board_name} set), and booting might be different than normal. Once you do boot it is recommended that you reinstall uboot with this command on the new card:
Code: Select all
$ sudo apt-get install --reinstall uboot

Details in this thread: viewtopic.php?f=95&t=28950
Last edited by mad_ady on Fri Jul 06, 2018 4:47 pm, edited 5 times in total.
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby biru585 » Thu Oct 06, 2016 12:26 am

hi, i have a problem, i want to try your tool but can't find the package sfdisk.
Code: Select all
odroid@odroid64:~$ sudo apt-get install sfdisk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package sfdisk



EDIT: i think it was already installed
Code: Select all
odroid@odroid64:~$ sfdisk -g
/dev/mmcblk0: 954240 cylinders, 4 heads, 16 sectors/track
/dev/sda: 182401 cylinders, 255 heads, 63 sectors/track
/dev/zram0: 3 cylinders, 255 heads, 63 sectors/track
/dev/zram1: 3 cylinders, 255 heads, 63 sectors/track
/dev/zram2: 3 cylinders, 255 heads, 63 sectors/track
/dev/zram3: 3 cylinders, 255 heads, 63 sectors/track
odroid@odroid64:~$

but can't find the package in synaptic, when i searched for it, the only result was libfdisk1.

i'm pretty noob so i wanted to be sure i was good to go :P ' before launching the tool. Can you confirm it's ok?
Sorry for my English
biru585
 
Posts: 26
Joined: Thu May 12, 2016 4:33 pm
languages_spoken: Italian, english
ODROIDs: C2

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Thu Oct 06, 2016 3:19 am

The command looks good, go ahead. I'll check the package name. The tool does a self-check when you start it and will complain if something's missing.
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby biru585 » Sat Oct 08, 2016 7:44 pm

i have a problem on my c2 with emmc. it doesn't recognize the emmc or the external hd (which i wanted to use for store the backup), only the usb pen.

here with the usb key
Image


here without
Image
Sorry for my English
biru585
 
Posts: 26
Joined: Thu May 12, 2016 4:33 pm
languages_spoken: Italian, english
ODROIDs: C2

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Sat Oct 08, 2016 8:03 pm

By default the command lists only removable devices. This is ok if you are running it on a PC with the emmc attached to abSD reader, but if you run the command on the odroid it will list the emmc/sd as non-removable. You can run the command with the -a switch to list all storage devices.
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Jojo » Thu Dec 15, 2016 4:41 am

Hi,

I am just trying to make a backup using your tool, but I encounter a problem:

After choosing the removable drive, it does not find any partitions, because the command "sfdisk -l -J /dev/xxx" seems to fail. And indeed, when I type in the command "alone", the "-l" option works, but the "-J" option doesn't (unrecognized option).

What I found:
THIS man page refers to the "-J" option, while THIS man page doesn't :shock: .
Any idea how to solve this?

Thanks and greetings

EDIT:
now I see, that my current desktop PC running Linux Mint 17 does NOT know the "-J" option, while my ODROID C2 DOES! But how do I get it running on my desktop PC?!
How to ask questions the smart way:
http://www.catb.org/esr/faqs/smart-questions.html
Jojo
 
Posts: 524
Joined: Mon May 18, 2015 12:13 am
Location: Germany
languages_spoken: english, german
ODROIDs: C1, C1+, C2, HC1, HC2, VU8C

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Thu Dec 15, 2016 4:22 pm

The -J option outputs as json, so it is easier to parse. Older Ubuntus (14.04) doesn't support it, and it seems Mint 17 is based on 14.04 LTS. You should upgrade to Mint 18 and you'll get the option, or, if it's not desirable, you can run the backup directly on the C2 (but you have to unmount /media/boot first). I've tried live backups and they work fine (provided that you don't edit a lot of files during the backup).
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Jojo » Thu Dec 15, 2016 7:53 pm

mad_ady wrote:The -J option outputs as json, so it is easier to parse. Older Ubuntus (14.04) doesn't support it, and it seems Mint 17 is based on 14.04 LTS. You should upgrade to Mint 18 and you'll get the option, or, if it's not desirable, you can run the backup directly on the C2 (but you have to unmount /media/boot first). I've tried live backups and they work fine (provided that you don't edit a lot of files during the backup).

Hi and thanks for the replay!

Roger that.
In the meantime, I have screwed up my whole desktop system by trying to upgrading only the package, that contains sfdisk to a newer version. This package is utils-linux. I compiled and installed the latest version manually and I really DO NOT (!!!) recommend that :lol: ! Details, see below.

On another system, the "-J" option works, but when I want to backup my ODROID system from a eMMC it says "/dev/sdc$ has a non-supported file system" for all four partitions (MBR, bootloader, boot, root) and no backup is created. Any idea how to solve that?

Thanks!

Off-Topic
How to repair a screwed up system after manually compiling and installing "util-linux":
I ended up with an unbootable system, saying that "libmount" (next to many more things) is missing, fs was read-only, nothing possible to do.
Then I took a Live-Linux flash drive (same version as the broken system -> Linux Mint 17.3 Rosa), copied the /bin/mount from the flash drive to my broken system partition. The next reboot into the broken system worked, although it was not very stable (no X, etc...). But from there I was able to reinstall the "normal" util-linux package again via apt-get. One more reboot aaand finally... everything was ok again 8-) .
Thanks to the post here: https://ubuntuforums.org/showthread.php?t=2082674
How to ask questions the smart way:
http://www.catb.org/esr/faqs/smart-questions.html
Jojo
 
Posts: 524
Joined: Mon May 18, 2015 12:13 am
Location: Germany
languages_spoken: english, german
ODROIDs: C1, C1+, C2, HC1, HC2, VU8C

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Thu Dec 15, 2016 9:13 pm

Well, that message appears if the type of the partition/filesystem is not vfat or ext2/3/4. The partition type should be reported by blkid for that partition. Can you show me the output of:
Code: Select all
blkid /dev/sdc1
blkid /dev/sdc2

Also, do you have any language set that might affect output for common programs? E.g. Does the output of the above commands vary when run prefixed with LANG=C?
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Jojo » Thu Dec 15, 2016 9:38 pm

Hi,

ok, I managed to make a backup and restore in textmode, no "unsupported filesystem" errors.

Anyway, I'd generally like to get it running in grafical mode as well. Could you please tell me how to perform this check you mentioned ("prefixed with LANG=C")?
How to ask questions the smart way:
http://www.catb.org/esr/faqs/smart-questions.html
Jojo
 
Posts: 524
Joined: Mon May 18, 2015 12:13 am
Location: Germany
languages_spoken: english, german
ODROIDs: C1, C1+, C2, HC1, HC2, VU8C

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Thu Dec 15, 2016 9:45 pm

In a terminal (started from the GUI) run the following comands and paste back the output here:
Code: Select all
blkid /dev/sdc1
LANG=C blkid /dev/sdc1

If your environment is in a different language than the standard ("C" = English) some programs might display different strings which can't be properly parsed.
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Jojo » Thu Dec 15, 2016 9:59 pm

I tried the following commands:
Code: Select all
blkid /dev/sdc1
LANG=C blkid /dev/sdc1
LANG=de_DE.UTF-8 blkid /dev/sdc1


The output is identical in all cases.
How to ask questions the smart way:
http://www.catb.org/esr/faqs/smart-questions.html
Jojo
 
Posts: 524
Joined: Mon May 18, 2015 12:13 am
Location: Germany
languages_spoken: english, german
ODROIDs: C1, C1+, C2, HC1, HC2, VU8C

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Thu Dec 15, 2016 10:06 pm

Can you post the output as well? I need to compare it with what the script sees.
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Jojo » Thu Dec 15, 2016 11:33 pm

Sure, this is what I get:
Code: Select all
LAPTOP-ACER jo # LANG=C blkid /dev/sdc1
/dev/sdc1: SEC_TYPE="msdos" LABEL="boot" UUID="0966-01D4" TYPE="vfat" PARTUUID="d3630000-01"
LAPTOP-ACER jo # blkid /dev/sdc1
/dev/sdc1: SEC_TYPE="msdos" LABEL="boot" UUID="0966-01D4" TYPE="vfat" PARTUUID="d3630000-01"
LAPTOP-ACER jo # LANG=de_DE.UTF-8 blkid /dev/sdc1
/dev/sdc1: SEC_TYPE="msdos" LABEL="boot" UUID="0966-01D4" TYPE="vfat" PARTUUID="d3630000-01"


I don't know how important this is, but as I switch.

Greetings
How to ask questions the smart way:
http://www.catb.org/esr/faqs/smart-questions.html
Jojo
 
Posts: 524
Joined: Mon May 18, 2015 12:13 am
Location: Germany
languages_spoken: english, german
ODROIDs: C1, C1+, C2, HC1, HC2, VU8C

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Fri Dec 16, 2016 11:38 pm

This is strange. The output looks ok and should work according to the script. Can you try to do a graphical backup and when it fails post the /var/log/odroid-backup.log to pastebin and link it here?
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Georacer » Tue Feb 14, 2017 6:50 am

Hello,

I'm trying to use the graphical tool but I'm getting errors and nothing gets backed up. The log is:

Code: Select all
$ cat /var/log/odroid-backup.log
Starting backup process
*** Starting to backup mbr ***
Error code: 0
label: dos
label-id: 0x3cedfd53
device: /dev/sdc
unit: sectors

/dev/sdc1 : start=        2048, size=      262144, type=c
/dev/sdc2 : start=      264192, size=    30851073, type=83
*** Starting to backup bootloader$ ***
*** Skipping partition bootloader$ because it has an unsupported type () ***
*** Starting to backup /dev/sdc2$ ***
*** Skipping partition /dev/sdc2$ because it has an unsupported type () ***
*** Starting to backup /dev/sdc1$ ***
*** Skipping partition /dev/sdc1$ because it has an unsupported type () ***


I've mounted the Odroid's SD card onto a card reader, on my Ubuntu 16.04 system.

Thanks in advance!
Georacer
 
Posts: 2
Joined: Mon Feb 13, 2017 4:35 am
languages_spoken: english
ODROIDs: XU4

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Wed Feb 15, 2017 4:38 am

Hmm, interesting. It can't detect the filesystem type, although sfdisk can. Are you running the command as root? Can you paste back the output of sudo blkid?
Also is your system in some locale where the default language is not english?
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Skipping partition because it has an unsupported type

Unread postby jk1 » Tue Feb 28, 2017 1:08 am

Hello,

I tried the backup tool today. Got similar type of error messages than the previous writer. backup-tool is installed on Ubuntu 16.04.2 laptop.

backup-tool printed following on the console:

Code: Select all
jk@koivu:~/Downloads$ sudo odroid-backup.pl
[sudo] password for jk:
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
backup
/sys/block/sda
sda   Samsung SSD 850   non-removable
/sys/block/sdb
$VAR1 = \'/dev/sdb';
blockdev: cannot open /dev/sdb: No medium found
Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/Number/Bytes/Human.pm line 231.
sdb   USB3.0 CRW   -SD   removable
/sys/block/sdc
$VAR1 = \'/dev/sdc';
sdc   USB3.0 CRW   -SD   removable
/sys/block/sr0
$VAR1 = \'/dev/sr0';
blockdev: cannot open /dev/sr0: No medium found
Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/Number/Bytes/Human.pm line 231.
sr0   DVD-RAM UJ8B1   removable
/sys/block/dm-0
dm-0      non-removable
/sys/block/dm-1
dm-1      non-removable
/sys/block/ram0
ram0      non-removable
/sys/block/ram1
ram1      non-removable
/sys/block/ram2
ram2      non-removable
/sys/block/ram3
ram3      non-removable
/sys/block/ram4
ram4      non-removable
/sys/block/ram5
ram5      non-removable
/sys/block/ram6
ram6      non-removable
/sys/block/ram7
ram7      non-removable
/sys/block/ram8
ram8      non-removable
/sys/block/ram9
ram9      non-removable
/sys/block/loop0
loop0      non-removable
/sys/block/loop1
loop1      non-removable
/sys/block/loop2
loop2      non-removable
/sys/block/loop3
loop3      non-removable
/sys/block/loop4
loop4      non-removable
/sys/block/loop5
loop5      non-removable
/sys/block/loop6
loop6      non-removable
/sys/block/loop7
loop7      non-removable
/sys/block/ram10
ram10      non-removable
/sys/block/ram11
ram11      non-removable
/sys/block/ram12
ram12      non-removable
/sys/block/ram13
ram13      non-removable
/sys/block/ram14
ram14      non-removable
/sys/block/ram15
ram15      non-removable
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
sdc$VAR1 = '{
   "partitiontable": {
      "label": "dos",
      "id": "0x3cedfd53",
      "device": "/dev/sdc",
      "unit": "sectors",
      "partitions": [
         {"node": "/dev/sdc1", "start": 2048, "size": 262144, "type": "c"},
         {"node": "/dev/sdc2", "start": 264192, "size": 31158272, "type": "83"}
      ]
   }
}
';
$VAR1 = {
          'partitiontable' => {
                                'unit' => 'sectors',
                                'partitions' => [
                                                  {
                                                    'start' => 2048,
                                                    'type' => 'c',
                                                    'size' => 262144,
                                                    'node' => '/dev/sdc1'
                                                  },
                                                  {
                                                    'size' => 31158272,
                                                    'node' => '/dev/sdc2',
                                                    'start' => 264192,
                                                    'type' => '83'
                                                  }
                                                ],
                                'label' => 'dos',
                                'id' => '0x3cedfd53',
                                'device' => '/dev/sdc'
                              }
        };
$VAR1 = \'/dev/sdc1';
$VAR1 = \'/dev/sdc2';
$VAR1 = {
          'bootloader' => {
                            'label' => 'Bootloader',
                            'sizeHuman' => '1.0MiB',
                            'end' => 2048,
                            'size' => 1048064,
                            'type' => 0,
                            'start' => 1
                          },
          '/dev/sdc2' => {
                           'sizeHuman' => '15GiB',
                           'start' => 264192,
                           'type' => '83',
                           'label' => 'rootfs',
                           'mounted' => '/media/jk/rootfs',
                           'literalType' => 'ext4',
                           'size' => '15953035264',
                           'uuid' => 'e139ce78-9841-40fe-8823-96a304a09859'
                         },
          '/dev/sdc1' => {
                           'sizeHuman' => '128MiB',
                           'start' => 2048,
                           'type' => 'c',
                           'size' => '134217728',
                           'label' => 'boot',
                           'mounted' => '/media/jk/boot',
                           'literalType' => 'vfat',
                           'uuid' => '52AA-6867'
                         },
          'mbr' => {
                     'type' => 0,
                     'start' => 0,
                     'size' => 512,
                     'label' => 'MBR+EBR',
                     'sizeHuman' => 512
                   }
        };
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
/dev/sdc1$,/dev/sdc2$,bootloader$,mbrGtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
/home/jk/tmp/odr-bckp-01Use of uninitialized value in string eq at /usr/local/bin/odroid-backup.pl line 154.
Use of uninitialized value in pattern match (m//) at /usr/local/bin/odroid-backup.pl line 163.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/odroid-backup.pl line 175.
Use of uninitialized value in string eq at /usr/local/bin/odroid-backup.pl line 154.
Use of uninitialized value in pattern match (m//) at /usr/local/bin/odroid-backup.pl line 163.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/odroid-backup.pl line 175.
Use of uninitialized value in string eq at /usr/local/bin/odroid-backup.pl line 154.
Use of uninitialized value in pattern match (m//) at /usr/local/bin/odroid-backup.pl line 163.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/odroid-backup.pl line 175.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.


The dialog box had following content:

Code: Select all
Starting backup process
*** Starting to backup mbr ***
Error code: 0
label: dos
label-id: 0x3cedfd53
device: /dev/sdc
unit: sectors

/dev/sdc1 : start=        2048, size=      262144, type=c
/dev/sdc2 : start=      264192, size=    31158272, type=83
*** Starting to backup bootloader$ ***
*** Skipping partition bootloader$ because it has an unsupported type () ***
*** Starting to backup /dev/sdc2$ ***
*** Skipping partition /dev/sdc2$ because it has an unsupported type () ***
*** Starting to backup /dev/sdc1$ ***
*** Skipping partition /dev/sdc1$ because it has an unsupported type () ***


And the output dir had only one file: partition_table.txt
which had following content:

Code: Select all
label: dos
label-id: 0x3cedfd53
device: /dev/sdc
unit: sectors

/dev/sdc1 : start=        2048, size=      262144, type=c
/dev/sdc2 : start=      264192, size=    31158272, type=83


sudo blkid shows this:

Code: Select all
jk@koivu:~$ sudo blkid
/dev/mapper/sda4_crypt: UUID="AN8ZRl-vA0S-c5HU-Eesr-LtlP-I6K0-NaMAiF" TYPE="LVM2_member"
/dev/mapper/vg_SSD-lv_root: LABEL="root" UUID="7483557a-5f70-4ca9-a290-e3fb55935ba1" TYPE="ext4"
/dev/sda1: LABEL="System Reserved" UUID="BAC4AC05C4ABC1CD" TYPE="ntfs" PARTUUID="6377e9d2-01"
/dev/sda2: UUID="A2C8C0C0C8C09447" TYPE="ntfs" PARTUUID="6377e9d2-02"
/dev/sda3: UUID="52f17e24-e22e-4335-9234-df22f254c0b1" TYPE="ext4" PARTUUID="6377e9d2-03"
/dev/sda4: UUID="522ec788-140a-42e9-9232-f49be5424faf" TYPE="crypto_LUKS" PARTUUID="6377e9d2-04"
/dev/sdc1: SEC_TYPE="msdos" LABEL="boot" UUID="52AA-6867" TYPE="vfat" PARTUUID="3cedfd53-01"
/dev/sdc2: LABEL="rootfs" UUID="e139ce78-9841-40fe-8823-96a304a09859" TYPE="ext4" PARTUUID="3cedfd53-02"


My locale shows this:

Code: Select all
jk@koivu:~$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=


I have tried this backup tool on couple of ubuntu 16.04 boxes with same results.

Whaẗ́s the reason for this error and how to fix it?

Thank you for your support.
jk1
 
Posts: 11
Joined: Fri Oct 14, 2016 9:06 pm
languages_spoken: english

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Tue Feb 28, 2017 3:20 am

Thanks for reporting. I'll have a look tomorrow to see what's wrong
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Tue Feb 28, 2017 4:51 pm

Ok, I've looked over the code and your output and it looks like the partitions are detected and classified correctly, but when iterating through that list I get an extra "$" sign appended to the partition name which breaks everything - e.g.:
/dev/sdc1$,/dev/sdc2$,bootloader$,mbr


I'm guessing this is introduced by $dialog->checklist which uses Zenity to display windows on screen and should return an array with what you selected. This array contains an extra $ at the end of most items (except the last - mbr - which is why mbr backup works).

I added a specific check and fixup for this case. Please download the code again from git and try again. Report back success or other issues :)
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby jk1 » Wed Mar 01, 2017 2:43 am

Thank you for the fast fix. I tried the new version. It seems that backup succeeds, atleast better than earlier, but restore fails and restored disk does not boot. Blue led is on, not blinking. Because the restore fails, there might also be errors in the backup and so I attached here results of the backup and restore.

I did this with a HP laptop running Ubuntu 16.04.2. Backup took about 12minutes while the restore took only less than half a minute so it is obvious that it cannot copy ~ 3-5 GB data in that time. Before restore I cleared the microSD card with dd about 5GB.

BACKUP

Backup dialog:

Code: Select all
Starting backup process
*** Starting to backup mbr ***
Error code: 0
label: dos
label-id: 0x3cedfd53
device: /dev/sdc
unit: sectors

/dev/sdc1 : start=        2048, size=      262144, type=c
/dev/sdc2 : start=      264192, size=    31158272, type=83
*** Starting to backup bootloader ***
2048+0 records in
2048+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,0368308 s, 28,5 MB/s
Error code: 0
*** Bootloader backup size: 1048576 bytes ***
*** Starting to backup /dev/sdc2 ***
Statistics for filesystem 0
* files successfully processed:....regfiles=135204, directories=14765, symlinks=57908, hardlinks=35, specials=80
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0
Error code: 0
====================== archive information ======================
Archive type:          filesystems
Filesystems count:       1
Archive id:          58b153f6
Archive file format:       FsArCh_002
Archive created with:       0.6.22
Archive creation date:       2017-02-28_18-55-17
Archive label:          <none>
Minimum fsarchiver version:   0.6.4.0
Compression level:       3 (gzip level 6)
Encryption algorithm:       none

===================== filesystem information ====================
Filesystem id in archive:    0
Filesystem format:       ext4
Filesystem label:       rootfs
Filesystem uuid:       e139ce78-9841-40fe-8823-96a304a09859
Original device:       /dev/sdc2
Original filesystem size:    14.62 GB (15702417408 bytes)
Space used in filesystem:    4.23 GB (4542263296 bytes)

*** Starting to backup /dev/sdc1 ***
Partclone v0.2.86 http://partclone.org
Starting to clone device (/dev/sdc1) to image (/home/jk/tmp/odr-bckp-03/partition_1.img)
Reading Super Block
Calculating bitmap... Please wait...
                                                                               
Elapsed: 00:00:01, Remaining: 00:01:39, Completed:   1,00%
                                                                               
Elapsed: 00:00:01, Remaining: 00:00:00, Completed: 100.00%
Total Time: 00:00:01, 100.00% completed!
done!
File system:  FAT16
Device size:  134,2 MB = 262144 Blocks
Space in use:  13,5 MB = 26304 Blocks
Free Space:   120,8 MB = 235840 Blocks
Block size:   512 Byte

                                                                               
Elapsed: 00:00:01, Remaining: 00:01:39, Completed:   1,00%,   0,00byte/min,

                                                                               
current block:          0, total block:     262144, Complete:   0,00%

                                                                               
Elapsed: 00:00:02, Remaining: 00:00:00, Completed: 100.00%, Rate: 404,03MB/min,

                                                                               
current block:     262144, total block:     262144, Complete: 100.00%
Total Time: 00:00:02, Ave. Rate:  404,0MB/min, 100.00% completed!
Syncing... OK!
Partclone successfully cloned the device (/dev/sdc1) to the image (/home/jk/tmp/odr-bckp-03/partition_1.img)
Cloned successfully.
Error code: 0
Partclone v0.2.86 http://partclone.org
Display image information
File system:  FAT16
Device size:  134,2 MB = 262144 Blocks
Space in use:  13,5 MB = 26304 Blocks
Free Space:   120,8 MB = 235840 Blocks
Block size:   512 Byte


Terminal output:

Code: Select all
jk@paju:~$ sudo odroid-backup.pl
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
backup
/sys/block/sda
sda   Samsung SSD 850   non-removable
/sys/block/sdb
$VAR1 = \'/dev/sdb';
blockdev: cannot open /dev/sdb: No medium found
Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/Number/Bytes/Human.pm line 231.
sdb   USB3.0 CRW   -SD   removable
/sys/block/sdc
$VAR1 = \'/dev/sdc';
sdc   USB3.0 CRW   -SD   removable
/sys/block/dm-0
dm-0      non-removable
/sys/block/dm-1
dm-1      non-removable
/sys/block/dm-2
dm-2      non-removable
/sys/block/ram0
ram0      non-removable
/sys/block/ram1
ram1      non-removable
/sys/block/ram2
ram2      non-removable
/sys/block/ram3
ram3      non-removable
/sys/block/ram4
ram4      non-removable
/sys/block/ram5
ram5      non-removable
/sys/block/ram6
ram6      non-removable
/sys/block/ram7
ram7      non-removable
/sys/block/ram8
ram8      non-removable
/sys/block/ram9
ram9      non-removable
/sys/block/loop0
loop0      non-removable
/sys/block/loop1
loop1      non-removable
/sys/block/loop2
loop2      non-removable
/sys/block/loop3
loop3      non-removable
/sys/block/loop4
loop4      non-removable
/sys/block/loop5
loop5      non-removable
/sys/block/loop6
loop6      non-removable
/sys/block/loop7
loop7      non-removable
/sys/block/ram10
ram10      non-removable
/sys/block/ram11
ram11      non-removable
/sys/block/ram12
ram12      non-removable
/sys/block/ram13
ram13      non-removable
/sys/block/ram14
ram14      non-removable
/sys/block/ram15
ram15      non-removable
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
sdc$VAR1 = '{
   "partitiontable": {
      "label": "dos",
      "id": "0x3cedfd53",
      "device": "/dev/sdc",
      "unit": "sectors",
      "partitions": [
         {"node": "/dev/sdc1", "start": 2048, "size": 262144, "type": "c"},
         {"node": "/dev/sdc2", "start": 264192, "size": 31158272, "type": "83"}
      ]
   }
}
';
$VAR1 = {
          'partitiontable' => {
                                'device' => '/dev/sdc',
                                'partitions' => [
                                                  {
                                                    'node' => '/dev/sdc1',
                                                    'size' => 262144,
                                                    'type' => 'c',
                                                    'start' => 2048
                                                  },
                                                  {
                                                    'type' => '83',
                                                    'start' => 264192,
                                                    'node' => '/dev/sdc2',
                                                    'size' => 31158272
                                                  }
                                                ],
                                'unit' => 'sectors',
                                'id' => '0x3cedfd53',
                                'label' => 'dos'
                              }
        };
$VAR1 = \'/dev/sdc1';
$VAR1 = \'/dev/sdc2';
$VAR1 = {
          'mbr' => {
                     'size' => 512,
                     'label' => 'MBR+EBR',
                     'start' => 0,
                     'sizeHuman' => 512,
                     'type' => 0
                   },
          'bootloader' => {
                            'size' => 1048064,
                            'type' => 0,
                            'sizeHuman' => '1.0MiB',
                            'start' => 1,
                            'end' => 2048,
                            'label' => 'Bootloader'
                          },
          '/dev/sdc2' => {
                           'label' => 'rootfs',
                           'sizeHuman' => '15GiB',
                           'type' => '83',
                           'start' => 264192,
                           'literalType' => 'ext4',
                           'size' => '15953035264',
                           'uuid' => 'e139ce78-9841-40fe-8823-96a304a09859'
                         },
          '/dev/sdc1' => {
                           'sizeHuman' => '128MiB',
                           'start' => 2048,
                           'type' => 'c',
                           'label' => 'boot',
                           'uuid' => '52AA-6867',
                           'size' => '134217728',
                           'literalType' => 'vfat'
                         }
        };
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
Partition list after select box: /dev/sdc1$,/dev/sdc2$,bootloader$,mbrPartition list after cleanup/dev/sdc1,/dev/sdc2,bootloader,mbrGtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
/home/jk/tmp/odr-bckp-03Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.


Log file:

Code: Select all
jk@paju:~$ sudo cat /var/log/odroid-backup.log
Starting backup process
*** Starting to backup mbr ***
Error code: 0
label: dos
label-id: 0x3cedfd53
device: /dev/sdc
unit: sectors

/dev/sdc1 : start=        2048, size=      262144, type=c
/dev/sdc2 : start=      264192, size=    31158272, type=83
*** Starting to backup bootloader ***
2048+0 records in
2048+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,0368308 s, 28,5 MB/s
Error code: 0
*** Bootloader backup size: 1048576 bytes ***
*** Starting to backup /dev/sdc2 ***
Statistics for filesystem 0
* files successfully processed:....regfiles=135204, directories=14765, symlinks=57908, hardlinks=35, specials=80
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0
Error code: 0
====================== archive information ======================
Archive type:          filesystems
Filesystems count:       1
Archive id:          58b153f6
Archive file format:       FsArCh_002
Archive created with:       0.6.22
Archive creation date:       2017-02-28_18-55-17
Archive label:          <none>
Minimum fsarchiver version:   0.6.4.0
Compression level:       3 (gzip level 6)
Encryption algorithm:       none

===================== filesystem information ====================
Filesystem id in archive:    0
Filesystem format:       ext4
Filesystem label:       rootfs
Filesystem uuid:       e139ce78-9841-40fe-8823-96a304a09859
Original device:       /dev/sdc2
Original filesystem size:    14.62 GB (15702417408 bytes)
Space used in filesystem:    4.23 GB (4542263296 bytes)

*** Starting to backup /dev/sdc1 ***
Partclone v0.2.86 http://partclone.org
Starting to clone device (/dev/sdc1) to image (/home/jk/tmp/odr-bckp-03/partition_1.img)
Reading Super Block
Elapsed: 00:00:01, Remaining: 00:00:00, Completed: 100.00%                     
Total Time: 00:00:01, 100.00% completed!
done!
File system:  FAT16
Device size:  134,2 MB = 262144 Blocks
Space in use:  13,5 MB = 26304 Blocks
Free Space:   120,8 MB = 235840 Blocks
Block size:   512 Byte
Elapsed: 00:00:02, Remaining: 00:00:00, Completed: 100.00%, Rate: 404,03MB/min,
current block:     262144, total block:     262144, Complete: 100.00%           
Total Time: 00:00:02, Ave. Rate:  404,0MB/min, 100.00% completed!
Syncing... OK!
Partclone successfully cloned the device (/dev/sdc1) to the image (/home/jk/tmp/odr-bckp-03/partition_1.img)
Cloned successfully.
Error code: 0
Partclone v0.2.86 http://partclone.org
Display image information
File system:  FAT16
Device size:  134,2 MB = 262144 Blocks
Space in use:  13,5 MB = 26304 Blocks
Free Space:   120,8 MB = 235840 Blocks
Block size:   512 Byte


Contents of the backup dir:

Code: Select all
total 2113084
drwxrwxr-x 2 jk   jk         4096 helmi 28 19:06 .
drwx------ 5 jk   jk         4096 helmi 28 18:54 ..
-rw------- 1 root root    1048576 helmi 28 18:55 bootloader.bin
-rw------- 1 root root   13839176 helmi 28 19:06 partition_1.img
-rw------- 1 root root 2148890741 helmi 28 19:06 partition_2.fsa
-rw------- 1 root root        181 helmi 28 18:55 partition_table.txt



RESTORE

Dialog:

Code: Select all
Starting restore process
*** Restoring MBR ***
Checking that no-one is using this disk right now ... OK

Disk /dev/sdc: 15 GiB, 16088301568 bytes, 31422464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3cedfd53

Old situation:

Device     Boot Start      End  Sectors Size Id Type
/dev/sdc1        2048 31422463 31420416  15G 83 Linux

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x3cedfd53.
Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 128 MiB.
/dev/sdc2: Created a new partition 2 of type 'Linux' and of size 14,9 GiB.
/dev/sdc3:
New situation:

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdc1         2048   264191   262144  128M  c W95 FAT32 (LBA)
/dev/sdc2       264192 31422463 31158272 14,9G 83 Linux

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Error code: 0
/dev/sdc: msdos partitions 1 2


Terminal output:

Code: Select all
jk@paju:~$ sudo odroid-backup.pl
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
restore
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
/home/jk/tmp/odr-bckp-03====================== archive information ======================

Archive type:          filesystems

Filesystems count:       1

Archive id:          58b153f6

Archive file format:       FsArCh_002

Archive created with:       0.6.22

Archive creation date:       2017-02-28_18-55-17

Archive label:          <none>

Minimum fsarchiver version:   0.6.4.0

Compression level:       3 (gzip level 6)

Encryption algorithm:       none



===================== filesystem information ====================

Filesystem id in archive:    0

Filesystem format:       ext4

Filesystem label:       rootfs

Filesystem uuid:       e139ce78-9841-40fe-8823-96a304a09859

Original device:       /dev/sdc2

Original filesystem size:    14.62 GB (15702417408 bytes)

Space used in filesystem:    4.23 GB (4542263296 bytes)


Partclone v0.2.86 http://partclone.org

Display image information

File system:  FAT16

Device size:  134,2 MB = 262144 Blocks

Space in use:  13,5 MB = 26304 Blocks

Free Space:   120,8 MB = 235840 Blocks

Block size:   512 Byte
$VAR1 = {
          'mbr' => {
                     'start' => 0,
                     'size' => 512,
                     'sizeHuman' => 512,
                     'literalType' => 'bin',
                     'filename' => '/home/jk/tmp/odr-bckp-03/partition_table.txt',
                     'label' => 'MBR+EBR'
                   },
          'bootloader' => {
                            'size' => 1048576,
                            'start' => 512,
                            'sizeHuman' => '1.0MiB',
                            'label' => 'Bootloader',
                            'filename' => '/home/jk/tmp/odr-bckp-03/bootloader.bin',
                            'literalType' => 'bin'
                          },
          '1' => {
                   'start' => 0,
                   'size' => 134217728,
                   'sizeHuman' => '128MiB',
                   'filename' => '/home/jk/tmp/odr-bckp-03/partition_1.img',
                   'literalType' => 'FAT16',
                   'label' => 'Partition 1'
                 },
          '2' => {
                   'filename' => '/home/jk/tmp/odr-bckp-03/partition_2.fsa',
                   'label' => 'Partition 2 (rootfs)',
                   'literalType' => 'ext4',
                   'size' => '15702417408',
                   'start' => 0,
                   'sizeHuman' => '15GiB'
                 }
        };
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
1$,2$,bootloader$,mbr/sys/block/sda
sda   Samsung SSD 850   non-removable
/sys/block/sdb
$VAR1 = \'/dev/sdb';
blockdev: cannot open /dev/sdb: No medium found
Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/Number/Bytes/Human.pm line 231.
sdb   USB3.0 CRW   -SD   removable
/sys/block/sdc
$VAR1 = \'/dev/sdc';
sdc   USB3.0 CRW   -SD   removable
/sys/block/dm-0
dm-0      non-removable
/sys/block/dm-1
dm-1      non-removable
/sys/block/dm-2
dm-2      non-removable
/sys/block/ram0
ram0      non-removable
/sys/block/ram1
ram1      non-removable
/sys/block/ram2
ram2      non-removable
/sys/block/ram3
ram3      non-removable
/sys/block/ram4
ram4      non-removable
/sys/block/ram5
ram5      non-removable
/sys/block/ram6
ram6      non-removable
/sys/block/ram7
ram7      non-removable
/sys/block/ram8
ram8      non-removable
/sys/block/ram9
ram9      non-removable
/sys/block/loop0
loop0      non-removable
/sys/block/loop1
loop1      non-removable
/sys/block/loop2
loop2      non-removable
/sys/block/loop3
loop3      non-removable
/sys/block/loop4
loop4      non-removable
/sys/block/loop5
loop5      non-removable
/sys/block/loop6
loop6      non-removable
/sys/block/loop7
loop7      non-removable
/sys/block/ram10
ram10      non-removable
/sys/block/ram11
ram11      non-removable
/sys/block/ram12
ram12      non-removable
/sys/block/ram13
ram13      non-removable
/sys/block/ram14
ram14      non-removable
/sys/block/ram15
ram15      non-removable
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
Selected disk is: sdc
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.


Log file:

Code: Select all
jk@paju:~$ sudo cat /var/log/odroid-backup.log
Starting restore process
*** Restoring MBR ***
Checking that no-one is using this disk right now ... OK

Disk /dev/sdc: 15 GiB, 16088301568 bytes, 31422464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3cedfd53

Old situation:

Device     Boot Start      End  Sectors Size Id Type
/dev/sdc1        2048 31422463 31420416  15G 83 Linux

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x3cedfd53.
Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 128 MiB.
/dev/sdc2: Created a new partition 2 of type 'Linux' and of size 14,9 GiB.
/dev/sdc3:
New situation:

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdc1         2048   264191   262144  128M  c W95 FAT32 (LBA)
/dev/sdc2       264192 31422463 31158272 14,9G 83 Linux

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Error code: 0
/dev/sdc: msdos partitions 1 2


I hope this helps to find out the problem.
jk1
 
Posts: 11
Joined: Fri Oct 14, 2016 9:06 pm
languages_spoken: english

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Wed Mar 01, 2017 2:01 pm

Yup, it's the same issue in the restore logic. The checkbox dialog returns an extra $ after each item except the last. I'll fix it and let you know. Backup looks fine so should be restorable.
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby jk1 » Wed Mar 01, 2017 5:04 pm

One further development wish:

Could it be possible to create a simple bash backup script with those parameters user gives during his interactive backup session?
E.g If user backups all partitions then create a script that backups all partitions. If user backups only partition 2 then create script that backups only partition 2.

Script does not need to have many arguments, maybe the output directory would be nice as an argument. Source device is also needed because it may vary depending on e.g. other usb devices attached.

That way user could run different backups non-interactively.
jk1
 
Posts: 11
Joined: Fri Oct 14, 2016 9:06 pm
languages_spoken: english

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Wed Mar 01, 2017 8:15 pm

I've pushed the fix on github. Please give it a try when you are able (restore-only is fine).

I'll consider adding command-line arguments for backup and restore. It shouldn't be complicated, though I need to make a bit of time. :)
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby jk1 » Wed Mar 01, 2017 11:28 pm

Now it works! I did backup & restore and XU4 runs fine with the restored sd-card.Thanks!!!

Command line arguments to the backup-tool would be great, too.

While you were fixing the backup-tool I tried to understand how the manual backup/restore works. I have couple of unclear issues:

As you can see in figure 3, the first partition (loop0p1) starts at offset 49152. So, we'll need to copy everything up to and including sector 49151. The bs (block size) parameter must match what sfdisk reported in the "Units" line:

Code: Select all
$ sudo dd if=/dev/mmcblk0 of=$backupDir/bootloader.bin bs=512 count=49151



I tried this with an image where first partition starts at 2048 and used command

Code: Select all
$ sudo dd if=/dev/mmcblk0 of=$backupDir/bootloader.bin bs=512 count=2047


but the bootloader.bin was smaller than what the backup-tool did. When I changed the command:

Code: Select all
$ sudo dd if=/dev/mmcblk0 of=$backupDir/bootloader.bin bs=512 count=2048


Sizes were same and md5sums of bootloader.bins matched. Are these count differencies meaningless or should the example command be

Code: Select all
sudo dd if=/dev/mmcblk0 of=$backupDir/bootloader.bin bs=512 count=49152



Another question:

You should also restore the bootstrap code from the first sector - you can do so with:
Code: Select all
$ sudo dd if=$backupDir/bootloader.bin of=/dev/mmcblk0 bs=446 count=1



From where does this bs=446 come from?

Thank you for your support.
jk1
 
Posts: 11
Joined: Fri Oct 14, 2016 9:06 pm
languages_spoken: english

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Wed Mar 01, 2017 11:35 pm

Regarding the first dd offset (2047 vs 2048), I think I may be wrong, and 2047 should be enough. You can try to restore your manual 2047 bootloader and it should work. The 2048th block should corespond to the first block of the first partition - so it's overlapping. I'll try to fix this when I get a bit of time.
The 446 byte mark comes from the bootcode part in the MBR structure (just before where the partition table starts). Look it up on wikipedia
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Trobin » Fri Mar 10, 2017 8:09 am

This tool doesn't works at all for me :cry:

When I launch your tool and click "OK" to select "backup" I have this :
Code: Select all
root@serdaigle:~ # odroid-backup.pl
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
root@serdaigle:~ #


In text mode it works BUT it says that my eMMC is non-removable (I launch it on my laptop) and it's the same thing for external USB HDD. It recognizes only my DVD and my pen drive.
(the image installed on my eMMC is Debian Jessie's image by meveric)

Terminal output :
Code: Select all
backup
/sys/block/sda
$VAR1 = \'/dev/sda';
sda   Samsung SSD 850   non-removable
/sys/block/sdb
$VAR1 = \'/dev/sdb';
sdb   Elements 1042   non-removable
/sys/block/sr0
$VAR1 = \'/dev/sr0';
sr0   DVD+-RW UJ8C2   removable
/sys/block/mmcblk0boot0
$VAR1 = \'/dev/mmcblk0boot0';
mmcblk0boot0      non-removable
/sys/block/mmcblk0boot1
$VAR1 = \'/dev/mmcblk0boot1';
mmcblk0boot1      non-removable
/sys/block/mmcblk0
$VAR1 = \'/dev/mmcblk0';
mmcblk0      non-removable


If I try with -a option and I select mmcblk0 to backup, I have this error :
Code: Select all
mmcblk0/sbin/sfdisk : option invalide -- 'J'

Utilisation :
 sfdisk [options] <périphérique> ...

Options :
 -s, --show-size           afficher la taille d'une partition
 -c, --id                  modifier ou afficher l'identifiant de partition
     --change-id           modifier l'identifiant
     --print-id            afficher l'identifiant
 -l, --list                afficher les partitions de chaque périphérique
 -d, --dump                identique, mais dans un format permettant une saisie ultérieure
 -i, --increment           nombre de cylindres, etc. à partir de 1 au lieu de 0
 -u, --unit <lettre>       unité à utiliser ; <lettre> peut être
                             S (secteur), C (cylindre), B (bloc) ou M (Mo)
 -1, --one-only            option réservée qui ne sert à rien pour le moment
 -T, --list-types          afficher les types de partitions connus
 -D, --DOS                 pour compatibilité DOS : perte d'un peu d'espace
 -E, --DOS-extended        compatibilité avec les partitions DOS étendues
 -R, --re-read             forcer le noyau à relire la table de partitions
 -N <numéro>               ne modifier que la partition de ce <numéro>
 -n                        ne pas écrire sur le disque
 -O <fichier>              sauvegarder les secteurs qui seront écrasés dans le <fichier>
 -I <fichier>              restaurer les secteurs de <fichier>
 -V, --verify              vérifier que les partitions affichées sont correctes
 -v, --version             afficher les informations de version et quitter
 -h, --help                afficher cette aide et quitter

Options dangereuses :
 -f, --force               désactiver toutes les vérifications de cohérence
     --no-reread           ne pas vérifier si la partition est utilisée
 -q, --quiet               supprimer les messages d'avertissement
 -L, --Linux               ne pas se plaindre de choses non pertinentes pour Linux
 -g, --show-geometry       afficher la géométrie d'après le noyau
 -G, --show-pt-geometry    afficher la géométrie d'après la table de partitions
 -A, --activate[=<périph>] activer l'indicateur d'amorçage
 -U, --unhide[=<périph>]   définir la partition comme non masquée
 -x, --show-extended       afficher aussi les partitions étendues en sortie ou
                             les descripteurs attendus en entrée pour elles
     --leave-last          ne pas allouer le dernier cylindre
     --IBM                 identique à --leave-last
     --in-order            les partitions sont dans l'ordre
     --not-in-order        les partitions ne sont pas dans l'ordre
     --inside-outer        toutes les partitions logiques dans une partition étendue à l'extrémité
     --not-inside-outer    pas toutes les partitions logiques dans une partition étendue à l'extrémité
     --nested              chaque partition est séparée de toutes les autres
     --chained             comme --nested, mais les partitions étendues peuvent
                             se situer en dehors
     --onesector           les partitions sont séparée réciproquement

Passer outre la géométrie détectée en utilisant :
 -C, --cylinders <nombre>  configurer le nombre de cylindres à utiliser
 -H, --heads <nombre>      configurer le nombre de têtes à utiliser
 -S, --sectors <nombre>    configurer le nombre de secteurs à utiliser

Consultez sfdisk(8) pour obtenir des précisions complémentaires.
$VAR1 = '';
$VAR1 = {
          'error' => {
                       'label' => 'Error running sfdisk. No medium?'
                     }
        };
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/odroid-backup.pl line 84.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/odroid-backup.pl line 90.
Use of uninitialized value in concatenation (.) or string at /usr/local/bin/odroid-backup.pl line 101.


Then in user interface I have this : "[*] error Error running sfdisk. No medium?, , type , start sector".
Trobin
 
Posts: 9
Joined: Sun Mar 13, 2016 9:35 pm
languages_spoken: french
ODROIDs: XU4

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Fri Mar 10, 2017 1:49 pm

Hmm, what linux version are you running on your laptop? sfdisk needs to be rather new to support output as json. This means it doesn't work pn ubuntu 14.04, but works in 16.04.
I'm not sure why the gui doesn't work. Perhaps the version of zenity is substantially changed as well.
Regarding non-removable drives - you'll need to run it with '-a'.
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Trobin » Fri Mar 10, 2017 10:02 pm

I'm running Debian 8.7 on kernel 4.9.0-0.bpo.2-amd64.
The version of sfidsk I have is sfdisk of util-linux 2.25.2.

I know why the GUI doesn't works, it's because my language settings were "fr_FR.UTF-8". I just have to export LANG='en_US' and GUI works.
Trobin
 
Posts: 9
Joined: Sun Mar 13, 2016 9:35 pm
languages_spoken: french
ODROIDs: XU4

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Sat Mar 11, 2017 4:16 am

Thanks for reporting. I'll need to fix the language problem in the code. Also, I'll need to support older sfdisk versions (can you paste a sfdisk -h?)
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Trobin » Sat Mar 11, 2017 6:54 am

Code: Select all
root@serdaigle:~ # sfdisk -h

Usage:
 sfdisk [options] <device>...

Options:
 -s, --show-size           list size of a partition
 -c, --id                  change or print partition Id
     --change-id           change Id
     --print-id            print Id
 -l, --list                list partitions of each device
 -d, --dump                idem, but in a format suitable for later input
 -i, --increment           number cylinders etc. from 1 instead of from 0
 -u, --unit <letter>       units to be used; <letter> can be one of
                             S (sectors), C (cylinders), B (blocks), or M (MB)
 -1, --one-only            reserved option that does nothing currently
 -T, --list-types          list the known partition types
 -D, --DOS                 for DOS-compatibility: waste a little space
 -E, --DOS-extended        DOS extended partition compatibility
 -R, --re-read             make the kernel reread the partition table
 -N <number>               change only the partition with this <number>
 -n                        do not actually write to disk
 -O <file>                 save the sectors that will be overwritten to <file>
 -I <file>                 restore sectors from <file>
 -V, --verify              check that the listed partitions are reasonable
 -v, --version             display version information and exit
 -h, --help                display this help text and exit

Dangerous options:
 -f, --force               disable all consistency checking
     --no-reread           do not check whether the partition is in use
 -q, --quiet               suppress warning messages
 -L, --Linux               do not complain about things irrelevant for Linux
 -g, --show-geometry       print the kernel's idea of the geometry
 -G, --show-pt-geometry    print geometry guessed from the partition table
 -A, --activate[=<device>] activate the bootable flag
 -U, --unhide[=<device>]   set partition as unhidden
 -x, --show-extended       also list extended partitions in the output,
                             or expect descriptors for them in the input
     --leave-last          do not allocate the last cylinder
     --IBM                 same as --leave-last
     --in-order            partitions are in order
     --not-in-order        partitions are not in order
     --inside-outer        all logicals inside outermost extended
     --not-inside-outer    not all logicals inside outermost extended
     --nested              every partition is disjoint from all others
     --chained             like nested, but extended partitions may lie outside
     --onesector           partitions are mutually disjoint

Override the detected geometry using:
 -C, --cylinders <number>  set the number of cylinders to use
 -H, --heads <number>      set the number of heads to use
 -S, --sectors <number>    set the number of sectors to use

For more details see sfdisk(8).



EDIT : I installed Ubuntu 16.04 and it works (even in french), thanks :)
Trobin
 
Posts: 9
Joined: Sun Mar 13, 2016 9:35 pm
languages_spoken: french
ODROIDs: XU4

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby sirzur » Thu Apr 20, 2017 4:48 pm

I have a problem with trying to back up my SD card. It cant seem to back up the boot partition. I have tried on a laptop running Ubuntu 16.04LTS and also on an Odroid U3 running 16.04 LTS with an external microSD card in a USB reader. (The microSD card also has the a spare operating system for the U3)

The GUI output recognizes the microSD card and all the partitions

Terminal Output
Code: Select all
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
   LANGUAGE = "en
en",
   LC_ALL = (unset),
   LC_PAPER = "en",
   LC_ADDRESS = "en",
   LC_MONETARY = "en",
   LC_NUMERIC = "en",
   LC_TELEPHONE = "en",
   LC_IDENTIFICATION = "en",
   LC_MEASUREMENT = "en",
   LC_TIME = "en",
   LC_NAME = "en",
   LANG = (unset)
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

(process:5979): Gtk-WARNING **: Locale not supported by C library.
   Using the fallback 'C' locale.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
backup
/sys/block/sda
sda   Storage Device   non-removable
/sys/block/sdb
$VAR1 = \'/dev/sdb';
sdb   Storage Device   removable
/sys/block/ram0
ram0      non-removable
/sys/block/ram1
ram1      non-removable
/sys/block/ram2
ram2      non-removable
/sys/block/ram3
ram3      non-removable
/sys/block/ram4
ram4      non-removable
/sys/block/ram5
ram5      non-removable
/sys/block/ram6
ram6      non-removable
/sys/block/ram7
ram7      non-removable
/sys/block/ram8
ram8      non-removable
/sys/block/ram9
ram9      non-removable
/sys/block/loop0
loop0      non-removable
/sys/block/loop1
loop1      non-removable
/sys/block/loop2
loop2      non-removable
/sys/block/loop3
loop3      non-removable
/sys/block/loop4
loop4      non-removable
/sys/block/loop5
loop5      non-removable
/sys/block/loop6
loop6      non-removable
/sys/block/loop7
loop7      non-removable
/sys/block/ram10
ram10      non-removable
/sys/block/ram11
ram11      non-removable
/sys/block/ram12
ram12      non-removable
/sys/block/ram13
ram13      non-removable
/sys/block/ram14
ram14      non-removable
/sys/block/ram15
ram15      non-removable
/sys/block/mmcblk0rpmb
mmcblk0rpmb      non-removable
/sys/block/mmcblk0boot0
mmcblk0boot0      non-removable
/sys/block/mmcblk0boot1
mmcblk0boot1      non-removable
/sys/block/mmcblk0
mmcblk0      non-removable

(process:6013): Gtk-WARNING **: Locale not supported by C library.
   Using the fallback 'C' locale.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
sdb$VAR1 = '{
   "partitiontable": {
      "label": "dos",
      "id": "0x9dc1001b",
      "device": "/dev/sdb",
      "unit": "sectors",
      "partitions": [
         {"node": "/dev/sdb1", "start": 6144, "size": 262144, "type": "6"},
         {"node": "/dev/sdb2", "start": 268288, "size": 62064641, "type": "83"}
      ]
   }
}
';
$VAR1 = {
          'partitiontable' => {
                                'partitions' => [
                                                  {
                                                    'start' => 6144,
                                                    'size' => 262144,
                                                    'type' => '6',
                                                    'node' => '/dev/sdb1'
                                                  },
                                                  {
                                                    'size' => 62064641,
                                                    'type' => '83',
                                                    'start' => 268288,
                                                    'node' => '/dev/sdb2'
                                                  }
                                                ],
                                'label' => 'dos',
                                'device' => '/dev/sdb',
                                'unit' => 'sectors',
                                'id' => '0x9dc1001b'
                              }
        };
$VAR1 = \'/dev/sdb1';
$VAR1 = \'/dev/sdb2';
$VAR1 = {
          'bootloader' => {
                            'type' => 0,
                            'sizeHuman' => '3.0MiB',
                            'size' => 3145216,
                            'label' => 'Bootloader',
                            'end' => 6144,
                            'start' => 1
                          },
          '/dev/sdb1' => {
                           'sizeHuman' => '128MiB',
                           'type' => '6',
                           'size' => '134217728',
                           'label' => 'BOOT',
                           'uuid' => '1B48-B34B',
                           'literalType' => 'vfat',
                           'mounted' => '/media/boot',
                           'start' => 6144
                         },
          'mbr' => {
                     'sizeHuman' => 512,
                     'type' => 0,
                     'label' => 'MBR+EBR',
                     'size' => 512,
                     'start' => 0
                   },
          '/dev/sdb2' => {
                           'label' => 'rootfs',
                           'size' => '31777096192',
                           'sizeHuman' => '30GiB',
                           'type' => '83',
                           'uuid' => 'e139ce78-9841-40fe-8823-96a304a09859',
                           'mounted' => '/',
                           'start' => 268288,
                           'literalType' => 'ext4'
                         }
        };

(process:6021): Gtk-WARNING **: Locale not supported by C library.
   Using the fallback 'C' locale.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
Partition list after select box: /dev/sdb1$,/dev/sdb2$,bootloader$,mbrPartition list after cleanup/dev/sdb1,/dev/sdb2,bootloader,mbr
(process:6024): Gtk-WARNING **: Locale not supported by C library.
   Using the fallback 'C' locale.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
/media/SGate160/Buffer/Odroid backup
(process:6040): Gtk-WARNING **: Locale not supported by C library.
   Using the fallback 'C' locale.
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.


The dialog box shows this message, and it is always the same message about not being able to read the partition 1 image (partition_1.img)
Code: Select all
Starting backup process
*** Starting to backup mbr ***
Error code: 0
label: dos
label-id: 0x9dc1001b
device: /dev/sdb
unit: sectors

/dev/sdb1 : start=        6144, size=      262144, type=6
/dev/sdb2 : start=      268288, size=    62064641, type=83
*** Starting to backup bootloader ***
6144+0 records in
6144+0 records out
3145728 bytes (3.1 MB, 3.0 MiB) copied, 1.84968 s, 1.7 MB/s
Error code: 0
*** Bootloader backup size: 3145728 bytes ***
*** Starting to backup /dev/sdb2 ***
Statistics for filesystem 0
* files successfully processed:....regfiles=129745, directories=14941, symlinks=58004, hardlinks=35, specials=99
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0
Error code: 0
====================== archive information ======================
Archive type:          filesystems
Filesystems count:       1
Archive id:          58f9ef5f
Archive file format:       FsArCh_002
Archive created with:       0.6.22
Archive creation date:       2017-04-20_17-29-44
Archive label:          <none>
Minimum fsarchiver version:   0.6.4.0
Compression level:       3 (gzip level 6)
Encryption algorithm:       none

===================== filesystem information ====================
Filesystem id in archive:    0
Filesystem format:       ext4
Filesystem label:       rootfs
Filesystem uuid:       e139ce78-9841-40fe-8823-96a304a09859
Original device:       /dev/sdb2
Original filesystem size:    29.13 GB (31277993984 bytes)
Space used in filesystem:    4.18 GB (4485816320 bytes)

*** Starting to backup /dev/sdb1 ***
Partclone v0.2.86 http://partclone.org
Starting to clone device (/dev/sdb1) to image (/media/SGate160/Buffer/Odroid backup/partition_1.img)
device (/dev/sdb1) is mounted at /media/boot
error exit
Partclone fail, please check /var/log/partclone.log !
Error code: 0
Partclone v0.2.86 http://partclone.org
Display image information
info: Can't open file(/media/SGate160/Buffer/Odroid backup/partition_1.img)
Partclone fail, please check /var/log/partclone.log !


Here is the partclone log
Code: Select all
Partclone v0.2.86 http://partclone.org
Display image information
info: Can't open file(/media/SGate160/Buffer/Odroid backup/partition_1.img)


Here is the odroid backup log
Code: Select all
Starting backup process
*** Starting to backup mbr ***
Error code: 0
label: dos
label-id: 0x9dc1001b
device: /dev/sdb
unit: sectors

/dev/sdb1 : start=        6144, size=      262144, type=6
/dev/sdb2 : start=      268288, size=    62064641, type=83
*** Starting to backup bootloader ***
6144+0 records in
6144+0 records out
3145728 bytes (3.1 MB, 3.0 MiB) copied, 1.84968 s, 1.7 MB/s
Error code: 0
*** Bootloader backup size: 3145728 bytes ***
*** Starting to backup /dev/sdb2 ***
Statistics for filesystem 0
* files successfully processed:....regfiles=129745, directories=14941, symlinks=58004, hardlinks=35, specials=99
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0
Error code: 0
====================== archive information ======================
Archive type:          filesystems
Filesystems count:       1
Archive id:          58f9ef5f
Archive file format:       FsArCh_002
Archive created with:       0.6.22
Archive creation date:       2017-04-20_17-29-44
Archive label:          <none>
Minimum fsarchiver version:   0.6.4.0
Compression level:       3 (gzip level 6)
Encryption algorithm:       none

===================== filesystem information ====================
Filesystem id in archive:    0
Filesystem format:       ext4
Filesystem label:       rootfs
Filesystem uuid:       e139ce78-9841-40fe-8823-96a304a09859
Original device:       /dev/sdb2
Original filesystem size:    29.13 GB (31277993984 bytes)
Space used in filesystem:    4.18 GB (4485816320 bytes)

*** Starting to backup /dev/sdb1 ***
Partclone v0.2.86 http://partclone.org
Starting to clone device (/dev/sdb1) to image (/media/SGate160/Buffer/Odroid backup/partition_1.img)
device (/dev/sdb1) is mounted at /media/boot
error exit
Partclone fail, please check /var/log/partclone.log !
Error code: 0
Partclone v0.2.86 http://partclone.org


Here is the partition_table.txt that is generated
Code: Select all
label: dos
label-id: 0x9dc1001b
device: /dev/sdb
unit: sectors

/dev/sdb1 : start=        6144, size=      262144, type=6
/dev/sdb2 : start=      268288, size=    62064641, type=83


Is there something I have to install ??

Thanks
sirzur
 
Posts: 24
Joined: Fri May 02, 2014 12:40 pm
languages_spoken: english
ODROIDs: U3 community

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Thu Apr 20, 2017 5:17 pm

Partclone doesn't have the ability to back-up mounted partitions:
Code: Select all
Starting to clone device (/dev/sdb1) to image (/media/SGate160/Buffer/Odroid backup/partition_1.img)
device (/dev/sdb1) is mounted at /media/boot
error exit

Before doing the backup you need to unmount /media/boot:
Code: Select all
sudo umount /media/boot
.
You can just redo the backup of the boot partition (without the other partitions).
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby sirzur » Thu Apr 20, 2017 5:46 pm

Ahhh! Thanks. That worked
sirzur
 
Posts: 24
Joined: Fri May 02, 2014 12:40 pm
languages_spoken: english
ODROIDs: U3 community

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby crazyquark » Sat Apr 22, 2017 7:11 pm

@mad_ady You rock, man!

I also like your byobu scripts

P.S.
You're never too old too learn python...
crazyquark
 
Posts: 280
Joined: Thu Jan 15, 2015 4:22 pm
languages_spoken: english, french, romanian
ODROIDs: C1,C1+,C2,HC1,XU4

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Sat Apr 22, 2017 9:11 pm

I'm glad somebody else likes byobu as well. I was familiar with screen, but I fell in love with that status bar. I also know that tmux has the same feature (and can look cooler).

Regarding python - I don't know. I gave it a try for new projects, but always came back to perl because I was familiar with the syntax and modules. I'd need to work on an existing python project in order not to switch. But there is time... :)
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby rooted » Sun Apr 23, 2017 7:31 am

Perl is actually pretty elegant when you're proficient.
User avatar
rooted
 
Posts: 5871
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Sun Apr 23, 2017 6:46 pm

The funny thing about perl is that you can abuse the syntax and write unreadable code :) like this: https://gist.github.com/mischapeters/1e ... aafd4f24f0
But my personal favourite is the abillity to write code in Latin: http://search.cpan.org/~dconway/Lingua- ... rligata.pm :D
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby rooted » Sun Apr 23, 2017 8:10 pm

mad_ady wrote:The funny thing about perl is that you can abuse the syntax and write unreadable code :) like this: https://gist.github.com/mischapeters/1e ... aafd4f24f0
But my personal favourite is the abillity to write code in Latin: http://search.cpan.org/~dconway/Lingua- ... rligata.pm :D

It has that regex looking syntax.
User avatar
rooted
 
Posts: 5871
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Bagman » Sun Jun 18, 2017 1:55 am

Perhaps this is just me being .. a new..

I used this tool and ended up with a

Bootloader.bin
partition_2.fsa
partition_3.fsa
partition_4.fsa
partition_table.txt

How do i make this into a image file
Bagman
 
Posts: 27
Joined: Fri Jul 29, 2016 1:32 am
languages_spoken: english

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby meveric » Sun Jun 18, 2017 2:15 am

This backup method does not create image files. It uses a different method to create backups from your system by doing a file backup rather than a block backup.

For .img files you need to use the "dd" under Linux/Mac or the Win32 Disk Imager under Windows.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.
User avatar
meveric
 
Posts: 9433
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Bagman » Sun Jun 18, 2017 2:30 am

OK Thank you !
Bagman
 
Posts: 27
Joined: Fri Jul 29, 2016 1:32 am
languages_spoken: english

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Sun Jun 18, 2017 4:04 am

This tool doesn't create images. An image traditionally copies data at a block level without caring about filesystem or free space.
This tool copies metadata and files and can recreate a working system on restore.
In your case, to write to a blank media you can use the restore functionality. It should have the same effect as flashing an image.

Edit: sorry - I didn't see the following page :)
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Quilope » Sat Aug 05, 2017 1:40 pm

Greetings,

I bought a C2, and I am trying to set it up - I'm totally new to Odroid, Linux, etc. I also purchased an emmc card with Ubuntu preinstalled, but it appears that LibreElec replaces the entire OS. Unless I'm mistaken.

I downloaded and installed Win32DiskImager, and tried to back up the contents of the emmc card. DiskImager will only recognize *.img files, and therefore won't recognize the contents of the emmc card as an OS.

Per the "backup strategies" instructions, I wrote "of=C:/documents/odroid_backups/backup.img bs=1M" into the code, and nothing happens when I click "read" or "write."

Any help will be appreciated, thank you.
Quilope
 
Posts: 5
Joined: Fri Aug 04, 2017 1:26 pm
languages_spoken: english
ODROIDs: C2

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Sat Aug 05, 2017 3:33 pm

Where did yo write that line? The dd command was intended to be run on a linux system, not windows.
Win32DiskImager should allow you to backup the whole emmc, but I haven't used it and I can't tell you the steps.
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Quilope » Mon Aug 07, 2017 1:56 pm

Yes, I'm on a Windows machine, thus I'm using Win32DiskImager. I wrote the line per your instructions, Mad_Ady.

I still can't figure out how to get it to work, so maybe I'll just skip the backup step. It'll be a shame, because this has a nice, clean, Ubuntu installation. This thing isn't doing much good just sitting around unused.
Quilope
 
Posts: 5
Joined: Fri Aug 04, 2017 1:26 pm
languages_spoken: english
ODROIDs: C2

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Mon Aug 07, 2017 2:58 pm

The tutorial I presented is designed to be run on Linux systems, where all the tools are available.
If you only have windows, try using Win32DiskImager to do a backup. Follow this guide: http://raspberrypihq.com/how-to-backup- ... pberry-pi/
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Quilope » Tue Aug 08, 2017 2:55 pm

Ahh, I didn't realize this guide is for linux users. And what a guide it is, Mad_Ady. It looks quite comprehensive - thank you for all this.

I tried doing what this Raspberry Pi guide says, and it's still not working. Now, Win32 Disk Imager is giving me this error message: "disk is not large enough for specified image write error 1.0"

*sigh*

I don't know if I am just *blessed*, but these things never seem to work out for me. I think I'll just proceed 'commando,' and hope I don't brick this thing. It's already been sitting around for a couple months, as I only assert myself when I feel I've got the patience for it. I am not a linux user, nor am I a code-writer, as it seems many of the folks here, are. I know this project, akin to the Raspberry Pi community, is do-it-yourself style. I had hoped I could get a media box up and running, but I'm afraid my newbness is showing.
Quilope
 
Posts: 5
Joined: Fri Aug 04, 2017 1:26 pm
languages_spoken: english
ODROIDs: C2

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby mad_ady » Tue Aug 08, 2017 3:17 pm

You should start a new thread describing what you've tried already and what has failed and the community will help you.
Also, if you don't want to spend too much time fiddling with linux internals (which we linux fan-boys actually enjoy doing), you should look into Android or the LibreElec project for your device.
User avatar
mad_ady
 
Posts: 4867
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [Howto] Odroid-Backup tool - backup and restore tool

Unread postby Quilope » Mon Aug 14, 2017 1:53 pm

I did get Win32 Disk Imager to work, eventually. Instead of writing the image to the C drive, I switched it over to my E drive, and it worked. Couldn't tell you why, but it did. My C drive is a SSHD, and the E drive is a platter drive. Don't know if that is pertinent here, but thought I'd mention it anyway.
Quilope
 
Posts: 5
Joined: Fri Aug 04, 2017 1:26 pm
languages_spoken: english
ODROIDs: C2

Next

Return to Ubuntu (All Linux'es)

Who is online

Users browsing this forum: No registered users and 1 guest