Question
Is it possible to create scheduled backup tasks via CLI/API?
Answer
Such functionality is yet to be implemented in Plesk.
If you would like to see these features in Plesk, please vote for them on Plesk UserVoice:
Available workarounds:
For Linux servers
A cron task can be added to schedule backups to a remote storage for example:
# echo '/usr/local/psa/bin/pleskbackup server --output-file=ftp://username:[email protected]/myfolder' > /etc/cron.weekly/99plesk-backup && chmod +x /etc/cron.weekly/99plesk-backup
For Windows servers
Note: for the following, the usage of Powershell is required.
Run the following commands to schedule a server-wide daily backup at 1am for example:
PS C:> $action = New-ScheduledTaskAction -Execute 'C:Windowssystem32cmd.exe' -Argument '/c "plesk bin pleskbackup --server"'
PS C:> $trigger = New-ScheduledTaskTrigger -Daily -At 1am
PS C:> $principal = New-ScheduledTaskPrincipal -UserId SYSTEM
PS C:> Register-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -TaskName "Daily Backup at 1am"
Using Extensions SDK (requires developer skills)
Create an extension to schedule tasks following our documentation: How to Create and Install Extensions and Extension SDK documentation: Scheduling Tasks