Backup and Restore

Introduction to Cloudmin Backups
--------------------------------------------------

Cloudmin allows the master administrator and system owners to create backups of virtual systems running under Xen, OpenVZ, Vservers or Solaris Zones. This provides protection against accidental deletion of files within the filesystem, for example by an accidental rm * command.

Backups can be either run manually or on a regular schedule, such as once per day. When a backup is taken the virtual system can be either shut down to ensure a consistent filesystem state, or left running to avoid downtime.

What is and is not Backed Up
--------------------------------------------

As of Cloudmin 6.2, backups include all details of selected systems - this allows deleted systems to be
re-created as part of the restore process. In older versions backups only include the contents of the virtual system's filesystem or disk images. For Xen systems the backup contains a compressed copy of all virtual disks, while for other virtualization types it is just a TAR file of the filesystem.

When backing up a running Xen system using LVM logical volumes to store disk images, LVM snapshots are used to take an instantaneous copy of the filesystem while it is copied. Each will consume 10% of the space in the volume group as the underlying disk images, so make sure you leave some LVM space free.

A multi-disk Xen or KVM system will have each disk stored in a separate file. Disks used for virtual memory or swap space will not be backed up, as the restore process always effectively reboots the system, meaning that memory contents do not need to be saved.

Backup Destinations
------------------------------

Cloudmin can backup virtual systems to a variety of different destinations - via SCP, FTP or to any system it manages. In a typical Cloudmin setup a single system with plenty of disk space is chosen as backup destination, perhaps the master system itself. Backups are taken on the host systems and then transferred to this backup machine. Alternately, you can choose to store backups on the hosts themselves, to avoid the need to transfer large backup files over the network.

Each host system defines a default backup destination for its virtual systems. You can set this as follows :

* Login to Cloudmin, open the *Host Systems* category and click on the link for your virtualization type, such as *Xen Host Systems*.
* Click on the first of your hosts, and open the *Default backup destination* section.
* Select a destination type and fill in the fields next to it - for example, in you have a dedicated backup system you could select *Directory on system*, choose it from the menu, and enter a path like /backup.
* Click the *Save* button, then repeat the same steps for other host systems.

When a backup is made it will be saved to the specified directory in a file whose name is that of the virtual system with .tar.gz appended. Each subsequent backup of the same system to the same destination will overwrite that file.

Creating a Scheduled Backup
-------------------------------------------

Once a default destination has been set, you can schedule a backup like so :

* Open the *Backup and Restore* category on the left menu and click on *System Backups*.
* Click the *Add a new system backup* link.
* From the *Systems to backup* list select the virtual systems you want to include.
* To have them shut down during the backup process, change *Shut down systems?* to *Yes*.
* In the *Backup destination*, you can typically leave *Default destination for host system* selected unless you want the backup to be sent to an FTP or SSH server outside of Cloudmin's control.
* Change *Scheduled backup enabled?* to *Yes*, and select a schedule in the *When to backup* field.
* To be notified on backup failures, enter your address in the *Email results to* field.
* Click the *Create* button.

It is possible to leave *Scheduled backup enabled?* set to *No* if you just want to define a backup that will always be run manually.

After a backup has been defined, you can edit or remove it by clicking on its entry in the *System Backups* list.

Running a Backup Manually
----------------------------------------

To kick off a backup, just click on it in the *System Backups* list and then hit the *Backup Now* button. Progress messages will be displayed as it runs, and a final summary of systems completed and backup sizes when it finishes. Depending on the sizes of the systems being backed up, it may take minutes or hours.

Testing a scheduled backup after creating it is strongly recommended. Also, you should create, backup and restore a test system that uses the same configuration and destination as your production systems to ensure that all steps in the process are working properly.

You can also back up a single system to an arbitrary destination using the *Backup System* menu item under *System State*. This form also allows the backup to be immediately downloaded from the user's browser, as well as writing to the destinations available for scheduled backups.

Backup Logs and Restoring Backups
------------------------------------------------------

Cloudmin logs all backups it performs, including their final status, systems included, disk used and possibly the complete progress report. To view logs, go to *Backup and Restore* -> *Backup Logs*, and enter a hostname or destination path into the *Find backup logs* box, then click *Search*.

The simplest way to restore a backup is to click on its destination in the search results, which will open a restore form. You can also restore some or all systems from a scheduled backup as follows :

* Go to *Backup and Restore* -> *System Backups*, and click on a backup.
* Click the *Restore* button.
* Select the systems to restore - typically you only want one, instead of everything that was included.
* Click *Restore Now*.

If the system no longer exists, the restore process will re-create it from details stored alongside the backup file. It will be re-created on the original host system with the same disk sizes, resource limits and ownership, if possible.

Using Backups To Migrate Systems
-----------------------------

As of Cloudmin 7.9, the backup/restore process can be used to migrate a VM to a new Cloudmin master. This can be done as follows :

* Backup the system to some directory on the original master.
* Transfer all the files whose name starts with the virtual system's hostname in the target directory to the new master system.
* Login to the new Cloudmin and go to *Backup and Restore* -> *Restore Backup*.
* In the *Virtual systems to restore* section, select * New system named* and enter the hostname of the VM being moved.
* In the *Restore from source* section, enter the host and directory containing the backup files.
* From the *Create missing systems on* menu, select an appropriate host system to create the system on.
* Click the *Restore Now* button.

Note that this process is NOT needed to move virtual systems between hosts controlled by a single Cloudmin master. However, it can be used to move between two Cloudmin GPL systems, or to another completely disconnected master server.