How to Backup Esxi ? | Esxi Backup
How to Schedule/Automate Esxi Backup ?
1. Create a directory to store backup files on your ESXi datastore.
mkdir /vmfs/volumes/datastore1/ESXi_backup
2. Create a script to back up ESXi configuration:
vi /vmfs/volumes/datastore1/ESXi_backup/esxi_backup.sh
3. Add the following lines to the script:
vim-cmd hostsvc/firmware/sync_config
vim-cmd hostsvc/firmware/backup_config
find /scratch/downloads/ -name *.tgz -exec cp {} /vmfs/volumes/datastore1/ESXi_backup/ESXi_config_backup_$(date +’%Y%m%d_%H%M%S’).tgz ;
Backup ESXi host configuration – creating a simple backup script
4. Save the file and quit vi:
:wq
Note: For greater convenience, you can also include the ESXi host name or IP address to the backup file name. This will help you to avoid confusion when using multiple ESXi hosts.
5. Make the script executable:
chmod +x /vmfs/volumes/datastore1/ESXi_backup/esxi_backup.sh
6. Go to the directory where the script is located:
cd /vmfs/volumes/datastore1/ESXi_backup/
7. Run the script:
./esxi_backup.sh
8. Verify that a backup file has been created:
ls -al
Backup ESXi host – a backup file is created
9. Let’s make sure the backup ESXi host script is running on schedule (automatically). Edit the scheduler configuration for this purpose:
vi /var/spool/cron/crontabs/root
10. Add the following string to perform ESXi configuration backup every hr in a day.
0 * * * * /vmfs/volumes/datastore1/ESXi_backup/esxi_backup.sh
11. Save changes in the file. In order to save changes in the read-only file, enter:
:wq!
As an alternative, you can change file permissions before editing the file:
chmod +w /var/spool/cron/crontabs/root
Backup ESXi host configuration – scheduling the backup process
After that, ESXi configuration will be backed up automatically as per the scheduleto the file named ESXi_config_bakup_date_time.tgz
[ad_2]
source