You should read the main documentation for the bareos vmware plug-in. Here is another good document well explains the data flow during backup and restore.
There are a number of limitations for restore that follow from the plug-in technology. First, there is no backup for the configuration file (VMX), so you can not restore the entire virtual machine from scratch. The only files that you can restore and perform a backup are the VMDK files that are in the "dependent" mode (attached only to this virtual machine). Shared disks are not supported at all.
A very painful limitation is the ability to restore only to the SAME VM where the backup was made. I tried to clone the original virtual machine, delete the original, and then clone back with the same name. This does not help. VmWare refuses to restore, because the disks do not match. As a solution, you can restore VMDK to local disks and then import it into a virtual machine. See below.
It's a general recommendation to turn off backup for what you are going to restore. A scheduled backup can lead to a conflict with the recovery process and must therefore be disabled.
Find the corresponding "*.conf" file and comment out the definitions of "Job {}". Then, reload the configuration and double-check that the backup job is undefined:
# echo reload | bconsole Connecting to Director localhost:9101 1000 OK: bareos-dir Version: 17.2.4 (21 Sep 2017) Enter a period to cancel a command. reload reloaded # echo "show jobs" | bconsole | grep -i myVm
When the restore is complete, revert the changes.
Turn off the virtual machine. In any case, you can not change the disk on the running operating system. OS will crush and could overwrite disk under restore.
Make clone the VM for reference. After a successful restore, this clone can be deleted. This clone holds the state before restore, and this really helped me in my experience in recovery.
NOTE: Restoring from WEB GUI does not work. You can select files, but the submitted job will fail.
Run "bconsole":
# bconsole Connecting to Director localhost:9101 1000 OK: bareos-dir Version: 17.2.4 (21 Sep 2017) Enter a period to cancel a command. *restore Automatically selected Catalog: MyCatalog Using Catalog "MyCatalog" First you select one or more JobIds that contain files to be restored. You will be presented several methods of specifying the JobIds. Then you will be allowed to select which files from those JobIds are to be restored. To select the JobIds, you have the following choices: 1: List last 20 Jobs run 2: List Jobs where a given File is saved 3: Enter list of comma separated JobIds to select 4: Enter SQL list command 5: Select the most recent backup for a client 6: Select backup for a client before a specified time 7: Enter a list of files to restore 8: Enter a list of files to restore before a specified time 9: Find the JobIds of the most recent backup for a client 10: Find the JobIds for a backup for a client before a specified time 11: Enter a list of directories to restore for found JobIds 12: Select full restore to a specified Job date 13: Cancel Select item: (1-13):
You can restore the last backup, then you need to select 5, or choose a known good date, then you need to select 6:
Select item: (1-13): 6 The restored files will the most current backup BEFORE the date you specify below. Enter date as YYYY-MM-DD HH:MM:SS :2018-08-31 00:00:00 Defined Clients: 1: bareos-fd .. Select the Client (1-3):
The remaining questions are the same, even though you choose 5 or 6. My "bareos-fd" daemon works on my server; he backed up, now he will restore:
Select the Client (1-3):1 The defined FileSet resources are: 1: Catalog .. 22: fileset-vm-myVm .. Select FileSet resource (1-24):22 +-------+-------+----------+----------------+---------------------+-------------------+ | jobid | level | jobfiles | jobbytes | starttime | volumename | +-------+-------+----------+----------------+---------------------+-------------------+ | 6,644 | F | 2 | 57,965,258,623 | 2018-08-03 22:21:29 | Full-0122 | | 6,644 | F | 2 | 57,965,258,623 | 2018-08-03 22:21:29 | Full-0123 | | 7,127 | D | 2 | 134,137,390 | 2018-08-24 21:12:55 | Differential-0101 | | 7,150 | I | 2 | 60,013,938 | 2018-08-25 21:02:48 | Incremental-0320 | | 7,174 | I | 2 | 102,831,899 | 2018-08-26 21:02:51 | Incremental-0320 | | 7,198 | I | 2 | 105,169,695 | 2018-08-27 21:02:48 | Incremental-0015 | | 7,198 | I | 2 | 105,169,695 | 2018-08-27 21:02:48 | Incremental-0186 | | 7,222 | I | 2 | 261,383,355 | 2018-08-28 21:02:53 | Incremental-0130 | | 7,246 | I | 2 | 38,959,033 | 2018-08-29 21:02:49 | Incremental-0189 | | 7,270 | I | 2 | 43,551,986 | 2018-08-30 21:05:08 | Incremental-0192 | +-------+-------+----------+----------------+---------------------+-------------------+ You have selected the following JobIds: 6644,7127,7150,7174,7198,7222,7246,7270 Building directory tree for JobId(s) 6644,7127,7150,7174,7198,7222,7246,7270 ... 8 files inserted into the tree. You are now entering file selection mode where you add (mark) and remove (unmark) files to be restored. No files are initially added, unless you used the "all" keyword on the command line. Enter "done" to leave this mode. cwd is: / $
Now we are in the "Select files" mode. We need all the files that make up single VMDK file. So just select them all:
$ mark * 8 files marked. $ done Bootstrap records written to /var/lib/bareos/bareos-dir.restore.3.bsr The job will require the following Volume(s) Storage(s) SD Device(s) =========================================================================== Full-0122 File FileStorage Full-0123 File FileStorage Differential-0101 File FileStorage Incremental-0320 File FileStorage Incremental-0015 File FileStorage Incremental-0186 File FileStorage Incremental-0130 File FileStorage Incremental-0189 File FileStorage Incremental-0192 File FileStorage Volumes marked with "*" are online. 8 files selected to be restored. Using Catalog "MyCatalog" Run Restore job JobName: RestoreFiles Bootstrap: /var/lib/bareos/bareos-dir.restore.3.bsr Where: /tmp/bareos-restores Replace: Always FileSet: LinuxAll Backup Client: bareos-fd Restore Client: bareos-fd Format: Native Storage: File When: 2018-09-11 12:25:03 Catalog: MyCatalog Priority: 10 Plugin Options: *None* OK to run? (yes/mod/no):
Although "Where" points to "/tmp/bareos-restores", it does not matter, because the plugin will restore file to its original location. So enter "yes" here and enjoy.
Find enough space to store the recovered file. It was obvious that I found the place on my bareos server in the "storage" directory.
# mkdir /var/lib/bareos/storage/tmp # chown bareos:bareos /var/lib/bareos/storage/tmp
Do the same steps as in the chapter above, untill the question "OK to run?". Then change some parameters:
OK to run? (yes/mod/no): mod Parameters to modify: .. 10: Where .. Select parameter to modify (1-14): 10 Please enter the full path prefix for restore (/ for none): /var/lib/bareos/storage/tmp Run Restore job JobName: RestoreFiles Bootstrap: /var/lib/bareos/bareos-dir.restore.4.bsr Where: /var/lib/bareos/storage/tmp Replace: Always FileSet: LinuxAll Backup Client: bareos-fd Restore Client: bareos-fd Format: Native Storage: File When: 2018-09-11 13:18:46 Catalog: MyCatalog Priority: 10 Plugin Options: *None* OK to run? (yes/mod/no): mod Parameters to modify: .. 14: Plugin Options Select parameter to modify (1-14): 14 Please enter Plugin Options string: python:localvmdk=yes Run Restore job JobName: RestoreFiles Bootstrap: /var/lib/bareos/bareos-dir.restore.4.bsr Where: /var/lib/bareos/storage/tmp Replace: Always FileSet: LinuxAll Backup Client: bareos-fd Restore Client: bareos-fd Format: Native Storage: File When: 2018-09-11 13:18:46 Catalog: MyCatalog Priority: 10 Plugin Options: python:localvmdk=yes OK to run? (yes/mod/no): yes Job queued. JobId=7559 You have messages. *exit
The resulting VMDK file is good for KVM, VmWare Workstation, Oracle VortualBox, but not for origianl ESX 6.5, where it came from.
Copy it to ESX:
# scp myVm.vmdk root@esx1:/vmfs/volumes/594b7717-b3665473-e1fb-a0369f81f298/myVM/myVm.vmdk-restored
Once copied, convert it to format suitable for ESX 6.5 . Login to ESX for this purpose and go to the directory with the uploaded file. Then run "vmkfstools":
[root@esx1:/vmfs/volumes/594b7717-b3665473-e1fb-a0369f81f298/myVM] vmkfstools -i myVm.vmdk-restored myVm.vmdk Destination disk format: VMFS zeroedthick Cloning disk 'myVm.vmdk-restored'... Clone: 100% done.
Now you can add a converted disk to any VM you want via VC GUI.
restore where=/var/lib/bareos/storage/tmp client=bareos-fd fileset=fileset-vm-myVm replace=always pluginoptions="python:localvmdk=yes" before="2018-08-18 00:00:00" done all yes