Applicable to:
- Plesk for Linux
- Plesk for Windows
Question
Is it possible to create scheduled backup tasks in Plesk via CLI/API?
Answer
Starting from Plesk Obsidian 18.0.61, it is possible to manage scheduled backups in Plesk using the following CLI utilities:
-
plesk bin scheduled-backup
- for configuring scheduled backups. -
plesk bin backup-storage
- for configuring FTP remote storage (other remote storages for backups can be configured only in the Plesk interface). -
plesk bin server_pref --update -backup-encryption-key-type <...>
- for selecting what is used for encrypting Plesk database passwords contained in backups - the Plesk encryption key or a password (analog of the option Tools & Settings > Backup Manager > Settings > Password type).
As for managing scheduled backups in Plesk via API, such functionality is yet to be implemented in Plesk. If you would like to see this feature in Plesk, please vote for it on Plesk UserVoice portal:
Available workarounds for Plesk versions prior to Plesk Obsidian 18.0.61:
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:password@example.com/myfolder' > /etc/cron.weekly/99plesk-backup && chmod +x /etc/cron.weekly/99plesk-backup
Note: for the following, the usage of PowerShell is required.
Run the following commands to schedule a server-wide daily backup at 1am:
PS C:> $action = New-ScheduledTaskAction -Execute 'C:\Windows\system32\cmd.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"
Create an extension to schedule tasks following our documentation: How to Create and Install Extensions and Extension SDK documentation: Scheduling Tasks
Comments
0 comments
Please sign in to leave a comment.