Learn how to manually back up both Ephemeral and Block Storage.

image

Ensuring that your OpenStack instances are backed up is an important part of disaster recovery planning. In this article, we’ll cover several possible methods for manually backing up an OpenStack instance with both Ephemeral Storage and Block Storage on Linux, and provide step-by-step instructions for each method.

Method 1: Snapshot the instance and its attached volumes

The first method we’ll cover is to take a snapshot of the instance and its attached volumes. This method involves using the OpenStack CLI tools to create snapshots of both the instance and its attached volumes, and then copying the snapshots to a backup location.

Step 1: Create a snapshot of the instance

To create a snapshot of the instance, use the openstack server image create command, specifying the name you want to give the snapshot and the ID of the instance you want to snapshot. For example:

openstack server image create --name myinstance_snapshot --wait 12345678-1234-5678-9012-34567890abcd

This will create a snapshot of the instance with the specified name, and the --wait option will cause the command to wait until the snapshot has been created before returning.

Step 2: Create a snapshot of each attached volume

To create a snapshot of each attached volume, use the openstack volume snapshot create command, specifying the name you want to give the snapshot and the ID of the volume you want to snapshot. For example:

openstack volume snapshot create --name myvolume_snapshot --volume 12345678-1234-5678-9012-34567890abcd

Repeat this step for each attached volume.

Step 3: Copy the snapshots to a backup location

Once you’ve created snapshots of both the instance and its attached volumes, you’ll want to copy them to a backup location for safekeeping. You can do this using the openstack image save and openstack volume snapshot save commands, respectively. For example:

openstack image save myinstance_snapshot --file myinstance_snapshot.qcow2
openstack volume snapshot save myvolume_snapshot --file myvolume_snapshot.qcow2

Repeat the second command for each attached volume.

Method 2: Backup the instance and its attached volumes using rsync

The second method we’ll cover is to use the rsync tool to copy the instance and its attached volumes to a backup location. This method requires that you have direct access to the host running the OpenStack instances.

Step 1: Identify the instance and its attached volumes

The first step is to identify the directory where the instance’s files are stored, as well as the mount points for each attached volume. The instance directory is usually located at /var/lib/nova/instances/<INSTANCE_ID>, where <INSTANCE_ID> is the ID of the instance you want to back up. You can use the openstack server show command to find the ID of the instance:

openstack server show myinstance

To find the mount points for each attached volume, you can use the openstack volume show command:

openstack volume show myvolume

Step 2: Copy the instance and its attached volumes using rsync

To copy the instance and its attached volumes to a backup location, use the rsync tool with the following command:

rsync -avz --exclude='/dev/*' --exclude='/proc/*' --exclude='/sys/*' --exclude='/run/*' --exclude='/mnt/*' --exclude='/media/*' --exclude='/lost+found' --exclude='/var/lib/nova/instances/*/console.log' <INSTANCE_DIR> <BACKUP_LOCATION>

Replace <INSTANCE_ID> with the ID of the instance you want to back up, and backup_location with the location where you want to store the backup. This command will exclude certain directories that don’t need to be backed up.

Method 3: Backup the instance and its attached volumes using tar

The third method we’ll cover is to use the tar tool to create a compressed archive of the instance and its attached volumes. This method also requires that you have direct access to the host running the OpenStack instances.

Step 1: Create a compressed archive of the instance and its attached volumes

To create a compressed archive of the instance and its attached volumes, use the following command:

tar -czvf backup.tar.gz /var/lib/nova/instances/<INSTANCE_ID> /dev/<VOLUME_NAME>

Replace <INSTANCE_ID> with the ID of the instance you want to back up, and <VOLUME_NAME> with the name of each attached volume. Repeat the last part of the command for each attached volume. This command will create a compressed archive named backup.tar.gz containing the specified directories.

Step 2: Copy the compressed archive to a backup location

Once you’ve created the compressed archive, copy it to a backup location using the scp or rsync tools. For example:

rsync -avz backup.tar.gz backup_location

Replace backup_location with the location where you want to store the backup.

Conclusion

Backing up your OpenStack instances is a crucial part of disaster recovery planning. In this article, we’ve covered several possible methods for manually backing up an OpenStack instance with Ephemeral Storage and Block Storage on Linux, including step-by-step instructions for each method. Whether you choose to use the OpenStack CLI tools, rsynctar, or a combination of these tools, it’s important to regularly back up your instances to ensure that you can recover quickly in the event of a disaster.