Schedule a Backup
Job
You can automate
the backup process by creating a schedule that runs backup jobs at specific
times.
- Verify that you can access the backup server and you have read and write permissions.
- Verify that you have established a connection to the vAPI services.
You can keep existing backups
on the backup server. The retention policy defines the maximum number of
backups that the server keeps. You can also specify whether the backup job
should run once, or on a recurring basis. The recurrence policy defines the
days of the week and specific times at which the backup job is scheduled to
run.
- Create a.Schedulesobject
- Specify the retention and recurrence information.
- Create a schedule by specifying the backup location, user credentials to access the location, retention, and recurrence information.
- Create anand pass the updated information.UpdateSpec
- Get a backup schedule by passing a schedule ID.
Run the backup job by using
the schedule.
- Python
- This example shows how you can schedule a backup job, update the schedule, and get a schedule. The example is based on thebackup_schedule.pysample.For a complete and up-to-date version of the sample code, see thevsphere-automation-sdk-pythonVMware repository at GitHub.... # Connect to vAPI services self.stub_config = vapiconnect.connect( host=args.server, user=args.username, pwd=args.password, skip_verification=args.skipverification) self.schedule_client = Schedules(self.stub_config) ... def create_schedule(self): retention_info = Schedules.RetentionInfo(self.max_count) recurrence_info = Schedules.RecurrenceInfo( days=self.days, hour=self.hour, minute=self.minute) create_spec = Schedules.CreateSpec( location=self.location, location_user=self.location_user, location_password=self.location_password, recurrence_info=recurrence_info, retention_info=retention_info) self.schedule_client.create(self._schedule_id, create_spec) def update_schedule(self): retention_info = Schedules.RetentionInfo(self.max_count) recurrence_info = Schedules.RecurrenceInfo( days=self.days, hour=self.hour, minute=self.minute) update_spec = Schedules.UpdateSpec( location=self.location, location_user=self.location_user, location_password=self.location_password, recurrence_info=recurrence_info, retention_info=retention_info) self.schedule_client.update(self._schedule_id, update_spec) def get_schedule(self): self.schedule_client = Schedules(self.stub_config) schedule_spec = self.schedule_client.get(self._schedule_id) recurrence_info = schedule_spec.recurrence_info retention_info = schedule_spec.retention_info table = [] data = [self._schedule_id, "{}:{}".format(recurrence_info.hour, recurrence_info.minute), " ".join(recurrence_info.days), retention_info.max_count] table.append(data) headers = ["Schedule ID", "Time", "Days", "Retention"] print(tabulate(table, headers)) ...