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

mrperfekotne
Posts: 138
Joined: Fri Nov 10, 2017 12:40 am
languages_spoken: Danish
ODROIDs: XU4
Has thanked: 0
Been thanked: 1 time
Contact:

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

Post by mrperfekotne »

Yes but I have not mounted it since the partition "mmcblk1p2" is a completely new partition that is being created during recovery with your script :/ -

Which you can also see in the log - Therefore, I do not understand openmediavault mount it :)

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Maybe omv has an automount feature? I mount it only if I need to

oddulf
Posts: 12
Joined: Mon Nov 12, 2018 8:42 pm
languages_spoken: english, swedish
ODROIDs: C1+, XU4Q
Has thanked: 0
Been thanked: 1 time
Contact:

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

Post by oddulf »

Hi, thank you for such a good summary on cloning and backup odroids!

When I first run odroid-backup.pl I get

Code: Select all

root@kir1:~# odroid-backup.pl
Can't call method "msgbox" on an undefined value at /usr/local/bin/odroid-backup.pl line 936.
I started installing the dependencies, but it fails with

Code: Select all

root@kir1:~# apt install libui-dialog-perl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libui-dialog-perl
Since you said the program does a self-check on startup, I'd thought I won't go searching for PPAs until it tells me to.

Odroid C1+, eMMC 8GB, official Ubuntu 18.04.01 minimal

Many thanks!
Ulf

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Ubuntu 18.04 dropped the libui-dialog-perl package. If you update the odroid-backup script with the latest git version it will tell you need to install "UI::Dialog" from CPAN instead.
Try

Code: Select all

sudo perl -MCPAN -e 'install UI::Dialog'

oddulf
Posts: 12
Joined: Mon Nov 12, 2018 8:42 pm
languages_spoken: english, swedish
ODROIDs: C1+, XU4Q
Has thanked: 0
Been thanked: 1 time
Contact:

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

Post by oddulf »

Thank you! - worked a treat on my Linux PC - will install it on the odroid too when the card is back in its place.

Apologies for the late reply - didn't get an email notification about your response...

ulfben
Posts: 112
Joined: Thu Jul 20, 2017 11:56 pm
languages_spoken: english
ODROIDs: XU4Q
Has thanked: 1 time
Been thanked: 1 time
Contact:

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

Post by ulfben »

I just did a fresh install from the github master, following the instructions there. Two observations: it seems the dependencies listed isn't quite complete, and the interactive console GUI shuts down instead of letting me select an output folder.

The dependencies listed on github says:

Code: Select all

$ sudo apt-get install zenity dialog libnumber-bytes-human-perl libjson-perl fsarchiver udev util-linux coreutils partclone parted
$ sudo perl -MCPAN -e 'install UI::Dialog'
Which leaves out mtd-utils? Running the script with no arguments (or just --backup) provided no output, until I ran it with --text, at which point the (ncurses?) GUI rendered and told me what was missing.

So dumping diagnostics / help text to console by default would help, I think.

Currently running a test backup. Thanks for putting this together!

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Yes, mtd-utils was added later (indended for N1 with a SPI flash chip). Sadly, GUI and text are both a bit problematic on recent ubuntu distros because of some problems with the libraries I'm using. Might need a redesign/rewrite.

User avatar
emk2203
Posts: 55
Joined: Fri Oct 16, 2015 12:29 am
languages_spoken: english, german
ODROIDs: C1+, C2, XU4, HC1, HC2, N2
Has thanked: 25 times
Been thanked: 0
Contact:

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

Post by emk2203 »

With the --text setting, I cannot restore a backup.

The menu says that I should select a directory, but whenever I press RETURN even after trying to select the NEXT button with TAB, the only action happening is that the directory opens.

When I try to select the /. entry there, I get a log of the backup process displayed in ncurses, but no restore action.

When I try to use command line only with

Code: Select all

root@XU4CS2T:/srv/samba/Stick60G/eMMC_backup# odroid-backup.pl --restore --disk mmcblk0 --partitions bootloader,mbr,1,2 --directory 20190205
an error occurs: Disk mmcblk0 is not a valid disk. Valid options are: sdb at /usr/local/bin/odroid-backup.pl line 559.

But obviously, mmcblk0 exists:

Code: Select all

root@XU4CS2T:/srv/samba/Stick60G/eMMC_backup# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda            8:0    0  1.8T  0 disk 
└─sda1         8:1    0  1.8T  0 part 
sdb            8:16   1 60.1G  0 disk 
├─sdb1         8:17   1    4G  0 part 
└─sdb2         8:18   1 56.1G  0 part /srv/samba/Stick60G
mmcblk0      179:0    0 58.2G  0 disk 
├─mmcblk0p1  179:1    0  128M  0 part 
└─mmcblk0p2  179:2    0 58.1G  0 part 
mmcblk0boot0 179:16   0    4M  1 disk 
mmcblk0boot1 179:32   0    4M  1 disk 
mmcblk0rpmb  179:48   0    4M  0 disk 
mmcblk1      179:64   0 14.9G  0 disk 
├─mmcblk1p1  179:65   0  128M  0 part /media/boot
└─mmcblk1p2  179:66   0 14.7G  0 part /
A bit inconvient for my barebones rescue over SSH now. What can I do to make the script work again? I don't want to manually do every step...

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Sorry about that. The perl modules I relied on for display are a bit broken. Try adding -a to show all disks, because mmcblk0 is not considered removable by default.

User avatar
emk2203
Posts: 55
Joined: Fri Oct 16, 2015 12:29 am
languages_spoken: english, german
ODROIDs: C1+, C2, XU4, HC1, HC2, N2
Has thanked: 25 times
Been thanked: 0
Contact:

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

Post by emk2203 »

Wow, I feel stupid now. I always have to use --text -a when doing backups for the exact same reason, but I overlooked that it is missing in my 'restore' command line.

Thanks!

leo117
Posts: 13
Joined: Fri Feb 02, 2018 11:13 am
languages_spoken: english
ODROIDs: Odroid-C2
Has thanked: 0
Been thanked: 0
Contact:

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

Post by leo117 »

I just made a backup but when i try to restore, it just shows the backup status window and does not do anything

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

As I said a few posts above, the display modules I rely on are broken and some dialogs (directory selection) are not shown anymore. For now you can still use the command line parameters:

Code: Select all

sudo ./odroid-backup.pl -a --restore --directory /path/to/backup/dir --disk /dev/sdd --partitions mbr,bootloader,1,2

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Ok, I made some time and did some tests. I also made a couple of corrections in the code. It seems that it works correctly when using zenity (the X11 dialog alternative), but directory selection dialogs don't work when using dialog (the shell equivalent of windows). Now instead of closing, the program will tell you what alternative to try to skip the directory selection (if it doesn't work on your system).

Should be more user friendly, without requiring a rewrite...

User avatar
meveric
Posts: 11161
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 47 times
Been thanked: 399 times
Contact:

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

Post by meveric »

You could try using whiptail menus instead. There's a nice filebrowser based on whiptail that someone wrote:
https://github.com/pageauc/FileBrowser
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.

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Haven't heard of whiptail until now. Will look into it, thanks

User avatar
meveric
Posts: 11161
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 47 times
Been thanked: 399 times
Contact:

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

Post by meveric »

whiptail is what was used in odroid-utilities (created by @mdrjr), or in my setup-odroid, cpu-control, odroid-server, and other tools which we're using since 2014 or so.
It's quite easy to understand and configure, and in many cases already pre-installed on the system compared to "dialog" which I've never seen part of an OS by default.
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.

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

I must be very old school then... I remembered dialog from my linux youth. I see it has perl bindings, so I'll test it tomorrow.

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Tried whiptail with the perl bindings. Sadly the windows are drawn with only a gray background (no visible text/buttons on them). You can still select things if you know where they are, but sadly it's a mess :(
Thanks for the tip though.

User avatar
meveric
Posts: 11161
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 47 times
Been thanked: 399 times
Contact:

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

Post by meveric »

mad_ady wrote:
Tue Apr 02, 2019 4:02 pm
Tried whiptail with the perl bindings. Sadly the windows are drawn with only a gray background (no visible text/buttons on them). You can still select things if you know where they are, but sadly it's a mess :(
Thanks for the tip though.
That sounds odd.. I use it all the time over different OSes (including Ubuntu), can you give me an example what you tried was it the filebrowser example and under which OS?
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.

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

I suspect it's the perl wrapper library that I'm using, not whiptail directly.

User avatar
meveric
Posts: 11161
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 47 times
Been thanked: 399 times
Contact:

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

Post by meveric »

As I don't know what you use it for and how you use it I can't help with that :(
I had very little trouble with whiptail up to now and grew quite fond of it.
Maybe you can circumvent your wrapper by starting whiptail with LD_PRELOAD and load the required libraries for whiptail directly.
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
nhiblot
Posts: 8
Joined: Wed Feb 22, 2017 7:04 am
languages_spoken: French / English
ODROIDs: C2
Has thanked: 0
Been thanked: 1 time
Contact:

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

Post by nhiblot »

Hi and Thanks for this great perl script

Since new version I have a problem only for restoring partition
Back Up works perfectly -
But when I want to make a restore
Selected disk to restore to is: stays always blank

The result of the restore action is display automatically (not restoring in fact ...)
and the window contains data but the restore is not done ....
Do you have any idea ?


###########################################################################################


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

/dev/sdc1 : start= 2048, size= 262144, type=c
/dev/sdc2 : start= 264192, size= 15003649, type=83
*** Starting to backup bootloader ***
2048+0 enregistrements lus
2048+0 enregistrements écrits
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,0527177 s, 19,9 MB/s
Error code: 0
*** Bootloader backup size: 1048576 bytes ***
*** Starting to backup /dev/sdc2 ***
Statistics for filesystem 0
* files successfully processed:....regfiles=44235, directories=4559, symlinks=10626, hardlinks=18, specials=79
* 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: 5cd9d3d3
Archive file format: FsArCh_002
Archive created with: 0.8.4
Archive creation date: 2019-05-08_18-22-31
Archive label: <none>
Minimum fsarchiver version: 0.6.4.0
Compression level: 8 (zstd level 8)
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: 7.04 GB (7561109504 bytes)
Space used in filesystem: 1.58 GB (1692508160 bytes)

*** Starting to backup /dev/sdc1 ***
Using partclone binary: partclone.vfat
Unmounting /media/nhiblot/boot...
Partclone v0.3.11 http://partclone.org
Démarrage clonage périphérique (/dev/sdc1) vers image (/home/nhiblot/TEST/partition_1.img)
Reading Super Block
Calculating bitmap... Please wait...

Ecoulé: 00:00:01, Restant: 00:01:39, Complété: 1,00%,

Elapsed: 00:00:01, Remaining: 00:00:00, Completed: 100.00%
Durée totale: 00:00:01, 100.00% completed!
done!
Système de fichiers: FAT16
Device size: 134,2 MB = 262144 Blocks
Space in use: 18,8 MB = 36700 Blocks
Free Space: 115,4 MB = 225444 Blocks
Taille de bloc: 512 octet

Ecoulé: 00:00:01, Restant: 00:01:39, Complété: 1,00%,, 0,00byte/mn
current block: 0, total block: 262144, Complete: 0,00%[A

Elapsed: 00:00:02, Remaining: 00:00:00, Completed: 100.00%, Débit: 563,71MB/mn,

current block: 262144, total block: 262144, Complete: 100.00%
Durée totale: 00:00:02, Débit moyen: 563,7MB/mn, 100.00% completed!
Syncing... OK!
Partclone a réussi à cloner le périphérique (/dev/sdc1) vers l'image (/home/nhiblot/TEST/partition_1.img)
Cloned successfully.
Error code: 0
Mounting back /media/nhiblot/boot (if it's in fstab)...
mount: /media/nhiblot/boot : impossible à trouver dans /etc/fstab.
Partclone v0.3.11 http://partclone.org
Showing info of image (/home/nhiblot/TEST/partition_1.img)
Système de fichiers: FAT16
Device size: 134,2 MB = 262144 Blocks
Space in use: 18,8 MB = 36700 Blocks
Free Space: 115,4 MB = 225444 Blocks
Taille de bloc: 512 octets

image format: 0002
created on a: 64 bits platform
with partclone: v0.3.11
bitmap mode: BIT
checksum algo: CRC32
checksum size: 4
blocks/checksum: 2048
reseed checksum: yes


###########################################################################################

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

If you don't see any disks in the restore window most likely they are not removable. Try running the command with "-a" so that it displays all disks.

User avatar
nhiblot
Posts: 8
Joined: Wed Feb 22, 2017 7:04 am
languages_spoken: French / English
ODROIDs: C2
Has thanked: 0
Been thanked: 1 time
Contact:

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

Post by nhiblot »

Hi

The list in the window is Full and I can select the disk I want
But when I click on OK, the window is closed directly

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

In that case you'll need to use the command-line parameters because the GUI isn't working correctly unfortunately :(
Here's an example:
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
You can specify some parameters and what is missing should be asked interactively.

dbod
Posts: 80
Joined: Fri Apr 26, 2019 10:03 pm
languages_spoken: english
ODROIDs: N2
Has thanked: 4 times
Been thanked: 1 time
Contact:

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

Post by dbod »

Code: Select all

db@odroid ~ ❯❯❯ sudo odroid-backup.pl --backup --disk mmcblk0 --partitions bootloader,mbr,/dev/mmcblk0p1,/dev/mmcblk0p2 --directory backup-emmc                                                                                       
DBG: rc=0
Disk mmcblk0 is not a valid disk. Valid options are:  at /usr/local/bin/odroid-backup.pl line 129, <NAND> line 0.000000.
db@odroid ~ ❯❯❯ ls /dev/mmc*  
/dev/mmcblk0  /dev/mmcblk0boot0  /dev/mmcblk0boot1  /dev/mmcblk0p1  /dev/mmcblk0p2  /dev/mmcblk0rpmb
db@odroid ~ ❯❯❯
The code is exactly taken from the example that you gave. The GUI version seems to work fine.

I guess there is a trivial solution to this. Which is it?

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Run it with -a as well.

dbod
Posts: 80
Joined: Fri Apr 26, 2019 10:03 pm
languages_spoken: english
ODROIDs: N2
Has thanked: 4 times
Been thanked: 1 time
Contact:

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

Post by dbod »

Will try. Thanks.

User avatar
nhiblot
Posts: 8
Joined: Wed Feb 22, 2017 7:04 am
languages_spoken: French / English
ODROIDs: C2
Has thanked: 0
Been thanked: 1 time
Contact:

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

Post by nhiblot »

Hi mad_ady

After some tests
The error when you select a disk is

Use of uninitialized value $selectedDisk in concatenation (.) or string at /usr/local/bin/odroid-backup.pl line 573.

I will try with command line but I prefer using GUI (because I'm not the only one to use it)

Regards

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Do you get a dialog window with available disks? Is it using gtk or ncurses (dialog) backend?

pat2
Posts: 67
Joined: Sun Jan 06, 2019 2:22 am
languages_spoken: english
ODROIDs: XU4Q
Has thanked: 2 times
Been thanked: 2 times
Contact:

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

Post by pat2 »

thanks a lot, mad.

I got an 32 GB eMMC and becoming crazy to move the contents of my 128 GB SD card to the eMMC (btw the SD content is less than 32 GB).
To avoid to build the eMMC from scratch.

At the end I succeded following your how-to post! With some difficulties, but I succeded. I will write better my suggestions.

Preliminarly:

- first, use Ubuntu 16.04 (I do not reccomend 18.04), I used a 16.04 istance on VMware,
- second, the tool with the graphic interface has issues, but the script works with commands -as suggested in the first post- through command line,
- third, if you have issues during restore phase you have to unmount the device you are trying to restore (I unmounted the first sdb1 and the second sdb2 partition in the hypothesis sdb is the target).

I will write a following post with the commands I used, That could be usefull for other newbie like me :-).

Anyway thanks Mad. You are great!
The system with eMMC (instead of SD) is more reactive and faster. And I avoided to rebuild from scratch.
Furthermore now the recovery backup copy is no more 128 GB long (previously obtained through dd command), but only 6 GB. :-)
These users thanked the author pat2 for the post:
mad_ady (Mon Jul 15, 2019 4:55 pm)

pat2
Posts: 67
Joined: Sun Jan 06, 2019 2:22 am
languages_spoken: english
ODROIDs: XU4Q
Has thanked: 2 times
Been thanked: 2 times
Contact:

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

Post by pat2 »

it works on Ubuntu 16.04

making the hypothesis that:

- the SD (the source) is in sdc
- the eMMC (the destination) is in sdb

Code: Select all

CTRL+ALT+T
you are in /home/michele

sudo apt-get install mtd-utils
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
sudo apt-get install libui-dialog-perl zenity dialog libnumber-bytes-human-perl libjson-perl fsarchiver udev util-linux coreutils partclone parted

sudo su
mkdir backup-emmc
sudo /usr/local/bin/odroid-backup.pl --backup --disk sdc --partitions bootloader,mbr,/dev/sdc1,/dev/sdc2 --directory /home/michele/backup-emmc
sudo umount /dev/sdb -v
sudo umount /dev/sdb1 -v
sudo umount /dev/sdb2 -v
sudo /usr/local/bin/odroid-backup.pl --restore --disk sdb --partitions bootloader,mbr,1,2 --directory /home/michele/backup-emmc

ab1jx
Posts: 102
Joined: Wed Jul 10, 2019 8:25 am
languages_spoken: english
Has thanked: 8 times
Been thanked: 4 times
Contact:

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

Post by ab1jx »

Piclone and clonezilla are also options. But those are for full backups. Daily use of rsynch will copy just what's changed, it overwrites a copy of a file if the date and size are different. You could keep a spare SD plugged into a USB reader and write scripts to mount it, do backups with rsynch, unmount it again, call that from a cron job so you don't forget to do it. Or use a hard drive.

But if a good version of a file gets automatically overwritten by a bad one you're sunk.

User avatar
meveric
Posts: 11161
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, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 47 times
Been thanked: 399 times
Contact:

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

Post by meveric »

ab1jx wrote:
Fri Jul 19, 2019 11:49 am
Piclone and clonezilla are also options. But those are for full backups. Daily use of rsynch will copy just what's changed, it overwrites a copy of a file if the date and size are different. You could keep a spare SD plugged into a USB reader and write scripts to mount it, do backups with rsynch, unmount it again, call that from a cron job so you don't forget to do it. Or use a hard drive.

But if a good version of a file gets automatically overwritten by a bad one you're sunk.
That is why I use backuppc from a different ODROID to backup my data. It will use rsync to do it's daily backups but also keeps a history so you have access to older files, even if your files got corrupted you can just go back a couple of days and get that file.
It also does pooling and compression, means the same file is only stored once even if you backup multiple devices and compression makes sure your harddrive does not blow up :D
here some current statistics:

Code: Select all

 There are 6 hosts that have been backed up, for a total of:

    20 full backups of total size 4868.51GB (prior to pooling and compression),
    30 incr backups of total size 73.21GB (prior to pooling and compression). 
So it has stored a total of nearly 5TB of backups
And this is the actual size:

Code: Select all

Pool is 583.36GB comprising 8328093 files and 4369 directories (as of 2019-07-18 21:24), 
ca. 8 million unique files, well I have the same files on different ODROIDs (source code) for different architectures and OS versions, I know for sure that the three biggest are all over 5mio files each :D
So that's a really nice cleanup.
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.

ab1jx
Posts: 102
Joined: Wed Jul 10, 2019 8:25 am
languages_spoken: english
Has thanked: 8 times
Been thanked: 4 times
Contact:

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

Post by ab1jx »

I was originally impressed by Piclone because it doesn't copy empty space. It sets up partitions on the destination to match the original, then it calls cp -ax to copy files, it's efficient that way. But I've found 2 flaws. (1) If you clone a Raspberry Pi SD card the Pi with the clone will get the same IP address from at least an Android DHCP server as the original. Different MAC address but if you clone a Pi they'll end up on the same IP and cause a conflict. The program author says it does what he intended it for and he's not going to fix it. The problem's unique to a Raspberry Pi I think and some of the files in /etc they use. The second I just found last night is that you can't use it to copy an SD in a reader to another SD in another reader on the same machine. It won't let you copy /dev/sdb to /dev/sdc if they're both SD cards. My /dev/sda is a hard drive in a USB case/adapter from Startech and I cloned it originally from an SD then modified my /etc/fstab and /boot/cmdline.txt so it would boot from the hard drive. But without rootwait in there it would crash whenever the hard drive spun down.

I just cloned the 32 GB card I was using yesterday onto a 128 GB by using dd, then adjusting the 2nd partition size with gparted and running fsck on it afterwards. Waiting for the 128 to arrive was what held up getting my Odroid running for a week.

I used to do backups as part of my last job, on a Windows NT server with a tape cartridge drive. There were daily incremental backups, weekly and monthly full backups, the log file was a spreadsheet with tape serial numbers, it was quite a project. But i was responsible for other people's data, never lost any in 9 years I was there. Now I don't do backups at all of my own stuff, I just copy stuff between machines often enough that not much is unique. I'm paranoid about losing my password files, I copy those around between machines.

jrabe
Posts: 17
Joined: Tue Dec 03, 2019 4:23 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 1 time
Been thanked: 1 time
Contact:

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

Post by jrabe »

Sorry to resurrect this thread from the dead.

I'm trying to backup eMMC to uSD. Using the Odroid backup perl tool I am able to select backupbackup partitions. Then it shows "Select items from the below list" but it is empty. Not sure if I'm missing something or if the backup tool is broken.
There is about 2 months worth of coding, settings, etc on this machine. I really don't want to wipe it out with me not understanding how to do a backup manually.

Its an XU4 with Ubuntu bionic beaver installed in an eMMC drive.

Thanks for any help / leads.

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Have you ran it with -a? You're running it from the system you want to back up, right?

ab1jx
Posts: 102
Joined: Wed Jul 10, 2019 8:25 am
languages_spoken: english
Has thanked: 8 times
Been thanked: 4 times
Contact:

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

Post by ab1jx »

dd will work in a pinch. Or mount the target and cp -a onto it. Or rsynch. If your work is in a few directories just cp -a them over. Use an SD in a USB reader.

Sounds like the backup tool is broken. If lsblk or sfdisk -l show them the backup tool should show them.. Maybe it only sees files of a certain type, never used it.

Put in a big enough SD to overwrite, then something like
dd if=/dev/mmcblk0 of=/dev/sda bs=1M status=progress
should copy everything on the mmc. It may take an hour or more, good thing to start at the end of the day and just let it run while you sleep. In principle the SD should be bootable afterwards, but you may have to switch something to make that the boot device. It will copy the operating system and everything, it's sort of overkill. There are backup programs like amanda or bacula. You probably have dd already.

You'll probably need to change the device names, I just grabbed those off this Pi I'm on. At the end of the name there's p0 and p1, those are partitions. Just don't specify them and dd will copy all the partitions.

jrabe
Posts: 17
Joined: Tue Dec 03, 2019 4:23 am
languages_spoken: english
ODROIDs: XU4
Has thanked: 1 time
Been thanked: 1 time
Contact:

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

Post by jrabe »

Thanks. I realized the -a addition to

Code: Select all

sudo odroid-backup.pl
from an early post. So much pseudo code in instructions makes it hard for us noobs to use. Maybe thats the point though.

I ran

Code: Select all

sudo odroid-backup.pl -a
and copied the 15 gig partition. I left all 4 items checked. It ran for 1.5hrs.
Previosly empty SD card now has the following files on it:
bootloader.bin (1MB)
partition_1.img (18.7MB)
partition_2.fsa (3.8GB)
partition_table.txt (195 bytes)

It wont boot from this sd card with the XU4 switch set to SD card (eMMC still in place.) I'm missing something still.
I do want to do a full copy.

Thanks guys. Next steps would be appreciated!

ab1jx
Posts: 102
Joined: Wed Jul 10, 2019 8:25 am
languages_spoken: english
Has thanked: 8 times
Been thanked: 4 times
Contact:

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

Post by ab1jx »

Bah, I see no pseudo code. Interesting, it makes an .img file. I've been trying (not too hard) to find a way to make efficient img files like what you download to write to an sd or mmc. The img size is the sum of the sizes of the files inside, maybe slightly over that. You can make img files with dd but it copies empty space, not very efficient.

You've probably got a backup of your files inside the img file, but you need to dig them out somehow. As far as booting, no, you've got one data partition with some files in it. partition_table.txt possibly explains it, I'm guessing that partition_2.fsa is the small /boot partition normally found on arm machines (which the xu4 isn't, I think) and partition_1.img is probably a normal Linux ext4 partition. But you'd need to restore them to another SD (or mmc, or ssd, or hard drive) to have it be bootable. Booting needs everything in the right place. When the machine starts it looks at a certain offset for the start of a bootloader, if it doesn't find one it ignores the drive. Mounting the sd and writing files to it is different than treating it as a block device where raw sectors get spit out as sectors, some of which may be the partition table, boot partition, data partiton. I can't think of a good analogy. A partition table is a few bytes on the drive which tells where (offsets) the partitions are.

dd will do what you want, it copies bytes from one place to another. You probably have it, type
man dd
at a command prompt. Lately I use it mostly for setting up swap files. IF is input file, which can also be a SD or disk or partition. OF is output file, same types apply. To make a swap file you copy from /dev/zero, which gets a stream of zeroes to a file that becomes the swap file. dd can copy a disk or partition to a file, or vice versa. BS is block size, the default will work but something like 1M (1,000,000 bytes) at a time is faster. status=progress is optional, otherwise it looks like nothing is happening for an hour or so. Don't mount the sd dd is copying to so it treats it as a block device. It should copy every byte from the mmc to the sd. I was a noob about 1995 but I learned fast enough to make a living with what I was learning, retired and bored now.

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

@jrabe The purpose of odroid-backup is to create and restore backups to/from image files. Not to transfer a system directly from emmc to sd. You can do it, but in two steps.
Step 1 - backup the running system to some external storage. In your case copy the files from the sd to some other storage.
Step 2 - Run the command again (with -a) and select restore. Select the storage where you have the img/fsa files, what to restore (everything) and where to restore it to (the sd card).

partition_1 is the small vfat partition, partition_2 is the linux partition. partition_table.txt describes the offsets in the partition table. bootloader.bin has the bootloader. The script takes care to backup/restore everything you need for a bootable system, without copying freespace. You could do it manually too, without the tool, as described in the first post.

ab1jx
Posts: 102
Joined: Wed Jul 10, 2019 8:25 am
languages_spoken: english
Has thanked: 8 times
Been thanked: 4 times
Contact:

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

Post by ab1jx »

That sounds good, I'll have to try it. Are you familiar with piclone? https://github.com/raspberrypi-ui/piclo ... master.zip Works moderately well on the Raspberry Pi's it was written for but seems to not find devices on anything else. It's in C with a GTK GUI. The heavy lifting is a popen call to cp -ax but it sets up partitions to match the original first. Probably could be made more universal.

The ironic thing is that if you use it on a Pi the machine with the clone gets assigned (by DHCP) the same IP as the original so you can't use it for like a classroom full of machines. That's caused I think by some extra file which Raspbian has in /etc. The MAC address is different, it's something else. Not hosts or interfaces.

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

No, I haven't tried piclone. If it uses cp (or rsync) it also needs to preserve partition uuids so that boot/fstab still works after restore. That's why I liked fsarchiver.

ab1jx
Posts: 102
Joined: Wed Jul 10, 2019 8:25 am
languages_spoken: english
Has thanked: 8 times
Been thanked: 4 times
Contact:

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

Post by ab1jx »

It has the option of making new ones. I don't like them so sometimes I don't use them, maybe it won't work without them. I used it once to clone an SD onto a hard drive and that actually booted and ran fine. But then I tried it on my Rock64 or N2 and it didn't work, didn't look into it. I think it also doesn't work to clone from one USB reader to another.

Image

mad_ady
Posts: 8486
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 578 times
Been thanked: 467 times
Contact:

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

Post by mad_ady »

Update: I created an ansible deploy recepie that can install the dependencies and odroid-backup (if it's easier to setup): https://github.com/mad-ady/ansible-odro ... ackup.yaml
These users thanked the author mad_ady for the post:
odroid (Mon Sep 07, 2020 9:19 am)

Post Reply

Return to “Ubuntu (All Linux'es)”

Who is online

Users browsing this forum: No registered users and 1 guest