Manual Data Recovery
Goal
- Downloading a snapshot of an instance
- Repairing the filesystem and mount it to extract data
Prerequisites
- You should be able to use simple heat templates, like shown in the getting-started guide.
- You know the basics of using the OpenStack CLI-Tools
- Environment variables are set, like shown in the API-Access How-To.
Optional: temporary work environment
Click
Temporary work environment
For this guide, we need a Linux environment and the OpenStack client in the OpenStack Cloud. If you do not have that yet, you can create it with the following commands:
wget https://raw.githubusercontent.com/syseleven/heat-examples/master/kickstart/kickstart.yaml
...
openstack stack create -t kickstart.yaml --parameter key_name=<ssh-key-name> <stack-name> --wait
...
Now we need to connect to the created instance.
The following commands need to be executed in the SSH session.
We also need the OpenStack credentials (openrc-file). You can download the OpenStack RC file from the user menu in the Horizon Dashboard.
Create and download a snapshot
To recover data from an existing instance, we have to create a snapshot first.
Warning
Creating instance snapshots of your server will make it unresponsive for some time (depending on the disk size).
We can download the snapshot now. This can take a while.
We can access the snapshot's contents via nbd.
sudo apt-get install -y qemu-utils
sudo modprobe nbd
sudo qemu-nbd --connect /dev/nbd0 snapshot.qcow2
Let's list the partitions.
$ sudo fdisk -l /dev/nbd0
Disk /dev/nbd0: 50 GiB, 53687091200 bytes, 104857600 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: 0x974bb19a
Device Boot Start End Sectors Size Id Type
/dev/nbd0p1 * 2048 104857566 104855519 50G 83 Linux
To repair the filesystem, use fsck.
Now we can mount the filesystem.
Conclusion
Now the data is accessible on /mnt/.
If it's an ext filesystem you should have a look in /mnt/lost+found.