Create Backup Workflow for VCSA 6
How to create a backup workflow for a Vcenter Server Appliance 6.
First of all we need to create a user on the vcenter:
ssh to the server and login with root (use your preferred ssh client)
Connected to service
* List APIs: “help api list”
* List Plugins: “help pi list”
* Enable BASH access: “shell.set –enabled True”
* Launch BASH: “shell”
Command> com.vmware.appliance.version1.localaccounts.user.add –role ‘superAdmin’ –fullname ‘backupUser’ –password –username backupUser
Enter password:
Reenter password:
Command> com.vmware.appliance.version1.localaccounts.user.list
Configuration:
Username: backupUser
Status: enabled
Role: superAdmin
Passwordstatus: valid
Fullname: backupUser
Email:
………
now we need to set make some configuration for the user. sudo access, group directory etc..
Command> shell.set –enabled True
Command> shell
chsh -s /bin/bash backupUser
groupadd backupAdmins
usermod -G superAdmin,backupAdmins backupUser
mkdir -p /opt/backup/python /opt/backup/root /storage/core/backups
chmod -R 770 /opt/backup /storage/core/backups
chown -R root:backupAdmins /opt/backup /storage/core/backups
With the root user we need to copy some python files. You can download this file 2091961_linux_backup_restore.zip. The KB located here.
Because we added the backupUser and enabled the user to use the bash, we can copy the file to the home drive of the backupUser
Now copy the file 2091961_linux_backup_restore.zip with the preferred SCP client to the home directory for root.
cd /opt/backup/python/
unzip /home/backupUser/2091961_linux_backup_restore.zip
chown backupUser:backupAdmins *
chmod 770 *
echo “backupUser ALL=NOPASSWD: /opt/backup/python/backup_lin.py,/usr/bin/scp,/usr/bin/sshpass” >> /etc/sudoers
We are now ready to execute python files on the vcenter server.
The workflow depends on a SFTP Server where the backup needs to be copied.
For this workflow i created a action and a workflow
The workflow can be downloaded here.
The action can be downloaded here.