• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Automating WordPress Backups with Plesk: Setting Up a Daily Cron Job for each domain

johannliebert

New Pleskian
Server operating system version
Ubuntu 22.04
Plesk version and microupdate number
18.0.62
Hello everyone,

I need help setting up a cron job on Plesk to automate daily backups of my WordPress site. I found the command used by Plesk's backup manager in the logs, but when I tried to use it in a cron job, I encountered errors related to task IDs not being found.

Here's what I've tried so far:

  1. Manually triggering a backup in Plesk and checking the logs for the command used.
  2. Setting up a cron job with the found command:

    /opt/psa/admin/bin/php /opt/psa/admin/plib/scripts/task-async-executor.php -task-id 1753
    This resulted in an error: Unable to find row with id 1753 in longtasks table.
After some research, I found that using the Plesk CLI directly might be a better approach. However, I’m unsure of the exact command syntax and the best way to set it up.

Can anyone provide guidance on:

  1. The correct Plesk CLI command to create a full backup (files and database) of a specific WordPress site?
  2. How to set up the cron job in Plesk to run this command daily?
PS: I know there are better ways, but I need a cron job.

Thanks in advance for your help!
 

Attachments

  • Screenshot 2024-07-15 140511.png
    Screenshot 2024-07-15 140511.png
    4.5 KB · Views: 6
  • Screenshot 2024-07-15 140542.png
    Screenshot 2024-07-15 140542.png
    13.3 KB · Views: 6
  • Screenshot 2024-07-15 140653.png
    Screenshot 2024-07-15 140653.png
    60.3 KB · Views: 6
In your screenshots I see backups that created by wp toolkit, not plesk. Anyway, you can use this wp-toolkit CLI command, and you can add it to cron (command can be run under root only)

1721050465624.png

P.S. you tried to run internal task that already done, it has no sense.
 
In your screenshots I see backups that created by wp toolkit, not plesk. Anyway, you can use this wp-toolkit CLI command, and you can add it to cron (command can be run under root only)

View attachment 26627

P.S. you tried to run internal task that already done, it has no sense.
thank you.

Maybe I need to specify:

I need just one command like this for Cron: This is an example for my database and works perfect.

Code:
/usr/bin/mysqldump -u Database user name -p'Database Password' Database Name > /var/www/vhosts/example.com/dump_$(date +\%F).sql && zip -j /var/www/vhosts/example.com/dump_$(date +\%F).sql.zip /var/www/vhosts/example.com/dump_$(date +\%F).sql && rm /var/www/vhosts/example.com/dump_$(date +\%F).zip
 
Code:
/sbin/plesk ext wp-toolkit --backup -instance-id 1 -path /httpdocs -operation backup
As @Evgeny already noted, this can only be ran as root user.

You can use the plesk ext wp-toolkit --list command to find the instance-id of a particular WordPress installation.
 
Code:
/sbin/plesk ext wp-toolkit --backup -instance-id 1 -path /httpdocs -operation backup
As @Evgeny already noted, this can only be ran as root user.

You can use the plesk ext wp-toolkit --list command to fin the instance-id of a particular WordPress installation.
thank you very much @Kaspar@Plesk , it works perfectly. Really nice Job.:):)

Now I Know how it's done.
Closed.
 
Back
Top