Hi,
I had a problem with one of the devices and I cannot access to the information recorded inside of one of the containers (DATABASE).
How can you access the container and recover the data?
Thanks!
Hi,
I had a problem with one of the devices and I cannot access to the information recorded inside of one of the containers (DATABASE).
How can you access the container and recover the data?
Thanks!
Hi, are you using balena cloud for managing devices? If so, why can’t you ssh into specific service container? Can you tell us more details of what you have tried so far?
Hi, Yes I’m using Balena Cloud but the device is not connecting anymore…
Hello there,
You should be able to recover the data, but to ensure that I give you clear directions, I’d like to clarify a couple of things:
main
) application, or a multicontainer application where the device is not working?With this information, I’ll craft a short set of instructions on how to go about recovering the data from the SD card under Linux.
Best regards,
Heds
Hi @jmzuazo,
I’ve written a brief guide assuming a multicontainer application, and how to get the volume data off the SD card on a Linux machine. Please let us know if anything’s unclear, or we can supply you with any more information.
CLONE THE SD CARD! This ensures we don’t do anything destructive to the card
Insert cloned SD card into Linux machine, in this example I’m using a USB convertor. Once inserted, a quick way to check what the SD card disk is called is to run dmesg:
$ dmesg
[2492110.746490] scsi 6:0:0:0: Direct-Access Generic- SD/MMC 1.00 PQ: 0 ANSI: 0 CCS
[2492110.747284] sd 6:0:0:0: Attached scsi generic sg4 type 0
[2492111.431717] sd 6:0:0:0: [sdd] 15523840 512-byte logical blocks: (7.95 GB/7.40 GiB)
[2492111.431965] sd 6:0:0:0: [sdd] Write Protect is off
[2492111.431973] sd 6:0:0:0: [sdd] Mode Sense: 03 00 00 00
[2492111.432205] sd 6:0:0:0: [sdd] No Caching mode page found
[2492111.433279] sd 6:0:0:0: [sdd] Assuming drive cache: write through
[2492111.445551] sdd: sdd1 sdd2 sdd3 sdd4 < sdd5 sdd6 >
[2492111.448176] sd 6:0:0:0: [sdd] Attached SCSI removable disk
As you can see, the SD card is /dev/sdd
and it contains 6 partitions.
$ fdisk -l /dev/sdd
Disk /dev/sdd: 7.4 GiB, 7948206080 bytes, 15523840 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: 0x5bc7238a
Device Boot Start End Sectors Size Id Type
/dev/sdd1 * 8192 90111 81920 40M c W95 FAT32 (LBA)
/dev/sdd2 90112 729087 638976 312M 83 Linux
/dev/sdd3 729088 1368063 638976 312M 83 Linux
/dev/sdd4 1368064 15523839 14155776 6.8G f W95 Ext'd (LBA)
/dev/sdd5 1376256 1417215 40960 20M 83 Linux
/dev/sdd6 1425408 15523839 14098432 6.7G 83 Linux
Now mount the data partition by using the offset. We want to create a new mount point on the local host to point the image at:
$ mkdir balena-data
$ mount -o loop,offset=$(( 1425408 * 512 )) /dev/sdd balena-data
/mnt/balena-data
directory. This includes all the writable data from the SD card. We’ll need to navigate into the docker volumes directory to find the relevant volumes attached to services:$ cd balena-data
$ ls -l
total 15
-rw-r--r-- 1 root root 3 Oct 28 14:42 apps.json
drwxr-xr-x 15 root root 1024 Sep 17 14:01 docker
drwx------ 2 root root 12288 Aug 13 09:49 lost+found
drwxr-xr-x 3 root root 1024 Oct 28 14:42 resin-data
$ cd docker/volumes
$ ls -l
total 27
drwxr-xr-x 3 root root 1024 Oct 28 14:42 1513354_datatest
drwxr-xr-x 3 root root 1024 Oct 28 14:42 1513354_twocontainer
-rw-r--r-- 1 root root 32768 Oct 28 14:42 metadata.db
The directory name suffixes correlate to the volumes defined in the docker-compose
manifest (if a single service application, there should only be one, with a UUID name). Any data created in the service will exist in these directories (within another _data
directory) ready to be copied off:
ls -l 1513354_datatest/_data/
total 1
-rw-r--r-- 1 root root 7 Oct 28 14:47 testfile
$ umount balena-data/
Best regards,
Heds
I was able to recover my DB
Thanks @hedss!!