Menu
Is free
check in
the main  /  Firmware / Backup VMware virtual machines. VMWare ESXI Virtual Machines Backup

Backup vmware virtual machines. VMWare ESXI Virtual Machines Backup

There is an excellent free script for backing up virtual machines on the VMware ESXI server, and it works on FREE version of ESXI 4 and 5 versions without installing any additional priblud type VMA, etc. The problem is only that the instruction is not entirely accurate there, so I talked with this script for a long time, so that he still earned in automatic mode ...

I will not write in detail in detail as a connection to ESXI on SSH, I will not write down only the steps of the setup, with which everything worked with me.

First, you swing the script on the link above and fill on the server, you need to pour right in the archive! The easiest way to do it through the vsphere client. I have two disks on my server - on one cars work, and on the other there are all sorts of ISO images and backups themselves. Called discs, respectively, DataStore1 and Datastore2. All backups, script and configs lie in the Backup folder. Still note that the names of files and folders are case-dependent, so if the folder is called backup., and you write in the script Backup., I will not work!

  1. Pour the archive with a script here / VMFS / Volumes / DataStore2
  2. Further in SSH cD / VMFS / VOLUMES / DATASTORE2 - Go to the script directory
  3. Unpack the script from the archive tAR -ZXVF_File_Archiva name.tar.gz.
  4. Vsphere to rename the unpacked folder into something easier, for example, just backup.
  5. Now let's go to this folder - cD Backup.
  6. Create a folder for storing individual configs inside it. mkdir BackupConfig
  7. Now B. BackupConfig We throw the right individual configs for machines, if they do not need and all machines need to be backing with the same settings, you can leave it empty
  8. Press via editor variables in the configuration file, the main thing is the path of the backup, i.e. The first line is changed to such: VM_BACKUP_VOLUME \u003d / VMFS / VOLUMES / DATASTORE2 / Backup, Well, then see what you still need - vI Ghettovcb.conf.
  9. Create script StartBackup.sh. (2 lines) - vI StartBackup.sh.
    2nd line where the challenge of the script itself can be removed upon itself
    CD / VMFS / VOLUMES / DATASTORE2 / Backup

    ./ghettovcb.sh -a -g ./ghettovcb.conf -c backupconfig -l ghettovcb.log
  10. Perform chmod + x ghettovcb.sh
  11. Perform chmod + x StartBackup.sh

1 stage completed! Now if you run StartBackup.sh.Bacup will begin. At the time of debugging, you can change the 2nd string on something like this ./ghettovcb.sh -a -g ./ghettovcb.conf -c backupconfig -l ghettovcb.log -d Dryrun - This will allow you to start the script and track the progress without copying the disks. To backups have been done more efficiently and quickly, I recommend setting the disk type in the settings. thin..

Configuring CRON (for automatic script run)

  1. Give permission to write to the file cHMOD + W.
  2. Add vi vi in / var / spool / cron / crontabs / root
    15 0 * / 3 * * /vmfs/volumes/DataStore2/Backup/startBackup.sh
    Run at 00:15 night every three days. I have a time zone +4 Moscow, i.e. In fact, the script starts at 4:15 in the morning, it will be seen by the date of change of the log via VSphere. Of course, time and frequency can choose others.
  3. Now you need to execute two commands to restart CRON
    kill $ (Cat /Var/run/crond.pid)
    crond.
  4. Add with VI 3 lines to the easiest file /etc/rc.local
    It is necessary, because after rebooting the server, the contents of the file from the 2nd point with the start of our script will be restored to the previous state, so in RC.Local, we specify that after rebooting you need to execute the following commands - Stop CRON, add a string for automatic launch Script and Running CRON.
    / BIN / KILL $ (Cat /Var/run/crond.pid)

    / bin / echo "15 0 * / 3 * * /vmfs/volumes/datastore2/backup/startbackup.sh" \u003e\u003e / var / spool / cron / crontabs / root
    crond.
  5. Now execute the command /sbin/auto-backup.sh.To make sure that all our changes have been preserved.

Small explanation - why you need to create a script StartBackup.sh.and not just take and its contents to put in / var / spool / cron / crontabs / root? There is some restriction on the size of this file and part of the strings in it simply will not work, although you can try to do and so, at first I worked, but then, apparently, some patches came out and stopped. Moreover, it is just more convenient - if you need to change the backup schedule, you just rule the file StartBackup.sh. and do not need dancing with a tambourine around Cron with his restart and making the same changes to /etc/rc.local.

PS: time goes, everything changes, the script itself changes, ESXI5 has already come out, so somewhere, something can not work already

Appendix: Cron Syntax

The CRON team looks like this:

1 2 3 4 5 /vmfs/volumes/DataStore2/Backup/startBackup.sh

Where,
1: Minutes (0-59)
2: Watch (0-23)
3: Days (0-31)
4: Months (0-12)
5: Day of the week (0-7)

A few examples:

  1. Running in 5 minutes first night, every day
    5 0 * * * /vmfs/volumes/DataStore2/Backup/startBackup.sh
  2. Run at 2:15 every first day of the month
    15 14 1 * * /vmfs/volumes/DataStore2/Backup/startBackup.sh
  3. Run at 22:00 every working day
    0 22 * \u200b\u200b* 1-5 /vmfs/volumes/Datastore2/Backup/startBackup.sh
  4. Running at 23 minutes after midnight and then every two hours (2:23, 4: 23 ... etc.), every third day
    23 0-23 / 2 * * * / 3 /vmfs/volumes/DataStore2/Backup/startBackup.sh

To organize a system of automatic backup of virtual machines running on the VMware ESXI server, we will use free utility Mksbackup., You can download which you can (at the time of writing the article, the latest available version of MksBackup 1.0.4 dated 24.01. 2013). This utility It is a peculiar frontand, which is integrated with various backup scripts, including Ghettovcb.(PERL backup script, written in Perl and supported by enthusiasts). GhettovCB allows B. online mode Create backup copies of running virtual machines. A backup copy of the VM is created by creating its snapshot (snapshot).

Important. Ghettovcb does not work with virtual machineshaving our own pictures. To perform a backup virtual machine All snapshots must be deleted (for example, via Snapshot Manager).

MksBackup is one of the few backup tools that allow you to perform online backup virtual machines. MksBackup can be used for virtual machine backups running both on the commercial edition of VMware ESXI and free VMware Hypervisor. The utility is designed for Python and is cross-platform. MksBackup utility does not have graphic interface, running through the command line, and configured through configuration files.

Naturally, the convenience and controllability of the solution for organizing the VMware virtual machines based on MksBackup, lower than that of commercial products, but a lot is compensated for its free, simplicity of tuning and deployment speed.

Installing the MksBackup backup script

Configure virtual machine backup settings

The next step is to configure the backup parameters of virtual machines running on the ESXI server. The setting is carried out by editing the mksbackup.ini configuration file (the default is in the C: \\ Magik folder).

Open the MKSBackup.ini file in any text editor. By its structure, the file is a few sections, the name of each section is enclosed in square brackets.
Section:

In this section, you can set the parameters of the alert e-mail. We are not interested in us, so we leave

Next section. This section is a referral task and describes various parameters that ensure the launch of the virtual machine backup in windows Environment. In our example, the task looks like this:

Program \u003d GhettovCB Host \u003d 10.10.1.89 port \u003d 22 login \u003d Root Password \u003d Li & F3CCC23 LOCAL \u003d C: \\ Magik \\ vmware global_conf \u003d ghettovcb.conf vm_list \u003d vm1_https WinXPTEST DESTINation \u003d C: \\ Magik \\ $ (VM) SCP_BIN \u003d "D: \\ INSTALL \\ PUTTY \\ PSCP.EXE "-Scp -R

Let us dwell on the settings:

program - Backup program, leave GhettovCB

host. - The name / IP of the ESXI host, on which virtual machines are running

port. - Port for access (by default 22 port - SSH protocol)

login. - the username with access rights to the ESXI server (by default it is root, but for the purpose of security it is better to start on the ESXI server server)

password. - Password of the user

local - Local directory in which the backup script is stored and its configuration

global_conf. - file with the settings of the ghettovcb script

vm_list. - A list of virtual machines for which you want to back up. If you need to take all the virtual machines, this parameter must be left blank. If you want to exclude some virtuals, use the VM_EXCLUDE parameter.

destination - The parameter allows you to specify the type of operation performed. It may be

  • backup - perform a simple backup (you do not need to specify the destination)
  • copy - Run backup and copy the received files to the specified directory.
  • move - Run backup and move the received files to the specified directory

Let us dwell on the MOVE version as more optimal. In this case, the ESXI host will create local backup copies of virtual machines, which will then be transferred to the computer running the script.

mON-SUN - It is assumed that the script can be performed daily (leave it, since the frequency of launching backup will be set via Windows Scheduler).

In addition, specify the directory to which backup copies of VM (C: \\ Magik) will be moved. The $ (VM) parameter indicates that a separate directory with its name will be created for each virtual machine where the shafts of the virtual machine will be folded.

Note. Detailed description The configuration settings of the script and its syntax is given on the developer's website.

sCP_BIN. - Path to SCP utility

Important. Make sure that the SSH daemon is turned on on the ESXI server.

VM_BACKUP_VOLUME \u003d / VMFS / VOLUMES / MSA2000 / Backup VM_BACKUP_ROTATION_COUNT \u003d 3

Vm_backup_volume - Directory on the ESXI server, in which copies of virtual machines will be saved (naturally, that the VMFS section should have enough free space)

Vm_backup_rotation_count - The number of stored local copies (in our example 3 latest backups will be stored)

It remains using the PLINK utility (also included in the package of Putty) Save the host key in the local Kesche SSH. For example, so:

Plink.exe. [Email Protected] Ls /

Start backup virtual machines on host VMware ESXI

Test the work of the backup script. For this, you need to open a command line with administrator rights and execute the command:

C: \\ Magik \\ MksBackup \\ MksBackup.exe -V -C C: \\ Magik \\ mksbackup.ini backup vmware_from_windows

Where is the key -V. Shows what you need to display detailed information, -c. path to the mksbackup.ini settings file, backup.- Means that you need to start backup, at the end specifies the name of the task from the file mksbackup.ini.(In our example, task VMware_From_Windows).

If everything is configured correctly, the utility will start in the console to display detailed information about the backup process (Cap the backup process is quite long, so you should not expect it to quickly complete).

The backup process can be traced by creating / removing snapshot events in the VMware vSphere console.

In the process of executing the script in the destination directory, folders containing virtual machine files will appear.

After completing the test copy, you can go to automation of the creation process. backups. To do this, create a new job scheduler.

Create, task with the name "Backup Esxi", which is performed on Fridays and launches the command: C: \\ Magik \\ mksbackup \\ mksbackup.exe -v -c-c: \\ Magik \\ mksbackup.ini Backup vmware_From_Windows

In the settings of the task, do not forget to specify that it needs to be run with administrator rights (option "Run with Highest Privileges").

Note. If the task will start on behalf of another account (Not the one under which testing was performed), it is necessary not to forget that in the cache of the new account there will be no necessary key. To solve the problem, you need to execute the above Plink command from under a new account.

Disadvantages of this this method Backup virtual machines:

  • pretty low backup speed
  • a large amount of free space required to store VM backups

These disadvantages are compensated by its free, but for large solutions, it is preferable to use commercial backup products, such as Veeam or HP DataProtector.

On the this moment There are several program manufacturers for storagesuch as paid and free. We decided that free programs Or uncomfortable in use (complex installation, constant threat of failure, lack of own interfaces), or there are no essential options backup. In this case, it is necessary to purchase paid programwhich, unlike free, will be fully workable with all the basic features of the backup. Below is a list of the best, according to experts, backed solutions:

    Veeam Backup & Replication 5

These programs are basic backup programs using most users:

    Data Recovery with Vcenter Server Support

As already written in the past, this is the surest way to create a backup machine if Vcenter Serve bought no desire or means to deal with this issue. Customizable this technology Pretty easy full guide You can find from the following link:

This solution works both with VCenterServer, and without it, but there will be no ability to set up a backup backup. We will look at all the main features just below when we compare all products.

    This product is now quite popular, as licensing type this product (licensed on sockets) for server-mounted servers will be extremely profitable. Below we consider several configurations of the servers and consider the price characteristics. Also, this product supports the instantaneous data recovery option after a failure due to its VPower technology.

    Recently, recently produces a means for backup in virtual environments. In addition, Symantec is the only one of all the bacap solutions uses V2P technology (converting a virtual environment to physical servers). True, VCenter has such technology, but not within the framework of backup technology

    But on this capabilities, Acronis is not limited. Acronis included in Acronis Backup & Recovery 10 AdvancedServer Virtualedition package another function, this is consolidating servers to transfer systems from physical on virtual platforms, and with a built-in task scheduler. As a result, we have that this program Performs 2 basic functions:

    • Emergency Recovery Systems

      Server consolidation

    Main advantages Compared to other technologies:

      Opportunity to work like with physical serversand in a virtual environment, which allows at the initial stages of the company's development to combine consolidation at high reliability estimates

      Wide range of supported backup storage devices (up to optical devices and magnetic tapes)

      Creating an Acronis Secure Zone partition on the same VM server, which allows you to restore the machine in a short time, and this section will be protected by deduplication mode on another server

      If the backup is one of our main goals, regardless of the price, we will undoubtedly choose between the decisions of the Veeam company, Acronisi Symantec. Both of these products are leaders of backup and storage, and also have a number of individual advantages.

      In the choice between these technologies, it is necessary to draw a line in several distinctions:

      1. Licensing type

        Characteristics

        Bacup volume and frequency

      For different type Licensing is worth deciding what the most suitable for us. If we have powerful servers with a lot of sockets under the processor, it is worth incurring in favor of Acronis Symantec. If we have a lot of weak servers with a small number of sockets, the best option There will be veeam.

      It is also necessary to understand what we need, that is, what requirements we will make to backup, the presence of those functions that are especially important to us.

      A very important factor, with what frequency and at what time we will make a backup. If we need to create backup machines for the entire infrastructure, and the frequency is unimportant, it is one (we put a backup scheduler at night). It's completely different if we have one priority machine, creating a backup for which we need from a period of a few minutes (it will already be necessary for a backup throughout the day).

      After determining for specific case All these parameters, it will be easy for us to decide for yourself which product suits us more.

If you have a desire to figure out in more detail in the configuration and network infrastructure, built on the basis of Linux, I recommend to get acquainted with Otus. The course is not for newcomers, for admission you need to go through.

If you have not yet configured a free Hyper-V hypervisor, I recommend to get acquainted with my material on this topic. If you have already set up and the question arose about how fast, conveniently and free to take it, then I recommend using the free HV Backup utility.

HvBackup Description Utilities for Hyper-V

The main goal of the HVBackup project was to create a free, simple and effective solution for backup virtual hyper-V machinesworking both in solitary mode and in the cluster.

The utility works on all versions operating system, beginning with Windows Server 2008 and further, both in graphical mode and Server Core installations. The utility supports including free editors Hyper-V Server hypervisor.

HvBackup supports the Hyper-V Crash Consistent App Consistent and Crash Consistent using VSS embedded in the system. There are many commercial solutions based on the same method of backup virtual machines, but only this product is known to me.

Company codeplex., manufacturer of the program, argues that it regularly uses HVBackup in its infrastructure, which guarantees high quality Work and timely corrections or changes.

The program can run from command line , call out PowerShellscripts or be built into any .NET Appendix Through the relevant library.

The principle of operation of this utility is quite simple. The program creates a separate directory in the specified directory. zip Archive For each virtual machine, which includes all the information relating to it.

System requirements:
.NET Framework 3.5.

Installation .NET Framework 3.5 on the command prompt

To install.NET Framework 3.5, you must execute the following commands in PowerShell.

Windows Server or Hyper-V Server 2012:

Install-WindowsFeature Net-Framework-Core

Windows Server 2008 or 2008 R2 (not Core):

OcSetup NetFx3.

Windows Server (CORE) or HYPER-V Server 2008/2008 R2:

OcSetup NetFX3-Servercore

HvBackup Example use

Run full VSS Backup all host virtual machines:

HVBACKUP -A -O D: \\ VM-Backup

Run the full VSS Backup list of virtual machines (you need to use quotes if the names of the machines contain spaces). Bacup is performed on a remote server:

HvBackup -L "VM1, VM2" -O \\\\ Backup-Server \\ WM-Backup

To do full backup Virtual machines, which contains in a text file (each VM in a separate line):

Hvbackup -f List.txt -o D: \\ WM-Backup

Script for automatic backup

If you want to schedule automatic backup execution, then it is more convenient to make a simple BAT file for these purposes and schedule its execution. Create backup-all.cmd. Next content:

Set BckPath \u003d "\\\\ Backup-Server \\ WM-Backup" REM NET USE% BCKPATH% / User: Pushd% BckPath% && forfiles.exe -m * .zip -D -7 -C "CMD / C Del @path" popd hvbackup.exe -a -o% bckpath% 1\u003e log_out.txt 2\u003e log_err.txt

This script before performing a backup of all virtual machines will delete zip files older than 7 days in the specified directory. Ways and parameters you can confirm under your needs.

Now let's create a scheduled job on a server for a periodic backup execution created earlier by a script:

Schtasks.exe / Create / TN HVBACKUP / TR C: \\ Backup-All.cmd / SC Daily / RU / RP / ST 01:00:00

If you need to delete the task:

Schtasks.exe / Delete / TN HVBACKUP / F

Immediate task execution:

Schtasks.exe / Run / TN HvBackup

HVBACKUP command line parameters

Use: hvbackup.exe.

-B, -Backup.
Run backup (default).
-R, -restore
Perform recovery.
-F, -file
Text filecontaining a list of virtual machines one in each row.
-L, -List.
List of virtual machines for backup.
-A -All
Backup All virtual machines on the server.
-N, -name
If it is indicated, the backup of only listed virtual machines is made.
-g, guid
If it is indicated, the backup of the listed virtual machines on the GUID are made.
-o, -Output
Mandatory parameter. End folder for archives. Maybe in the form of a local or network path.
-Outputformat.
Virtual machine archive name format. (0) Machine name, (1) GUID Machines and (2) Current Date and Time. Default: "(0) _ (2: yyyymmddhhmmss) .zip"
-s, -singlevss
Make one snapshot for all virtual machines.
-Help
Display certificate for teams:

Conclusion

That's all. The only remark - I did not test the drop in performance while the backup is performed. I did not notice any brakes in the work of virtual machines. But they were all unloaded. The time of performing a backup of each machine is significant. But, of course, it depends on the set of factors.

there is good opportunity Align HVBackup and. For example, making archives locally on the server with Hyper-V, mount the folder to the Linux server and use Rsync to select zip files with virtual machines. Either immediately make backup to Linux Sambu, for example. According to the above link, there is an example on this topic.

Online course Security Linux

If you have a desire to understand more detail in the configuration and security and network infrastructure, built on the basis of Linux, I recommend to get acquainted with online course "Security Linux" in Otus. Training lasts 3 months, after which successful graduates of the course will be able to interview partners. The course program is designed as a series of practical workshops and is focused on prepared listeners who already have knowledge and experience in the Linux administration. What will learn:
  • Apply the best world practices and IB standards (Debian, Redhat, Mitre);
  • Use means for detecting and operating vulnerabilities in Linux OS;
  • Install and configure network systems detection and preventing attacks;
  • Work with docker monitoring and containerization systems;
Check yourself on the introductory test and see more detailed software program.

To create backups VMware in Handy Backup, two methods can be used: internal and external.

Internal method

A copy of the Handy Backup is installed on the VMWare virtual machine running Windows or Linux. Operation Handy Backup on a virtual machine is no different in principle from using a similar solution on "physical" computers.

External method

Handy Backup runs on VMware virtual machines to copy the images of specific VMWare copies as regular files. Handy Backup uses a special plugin that works in the "hot" mode to backup machines and array of VMware (without stopping the VMWare machine).

How to save vmware virtual machine

Copying the image of VMWare Backup is made using a specialized tool. Using the VMware plug-in settings, you can also stop the VMWare copied machine and its subsequent restart for "cold" copying.

  1. Open the Handy Backup and create a new task by pressing Ctrl + N or selecting the menu item. Select the backup task.
  2. In step 2, select Plugin " VMware Workstation.".

  1. Double-click on the "New Configuration" line to select the access configuration to VMware.
  2. In the dialog that opens, make a choice between modes " Hot."(backup without stopping the machine) and" Enable Suspend."(with a stopping of a virtual machine to get its exact image).

  1. Next, select the specific image of the machine to which this configuration will be applied in the dialog.

  1. Click "OK" and continue creating a task as usual.

The sequence described above will stop, and then restart VMware virtual machines without any additional intervention.