C Panel Access Menu

Schedule cPanel Backup task via CRON

How to schedule the cPanel backup process to run as a task:
Recently, a TCH user asked: "How can I set up a cronjob to run (say every morning at 3:30am) to perform the cPanel home directory backup and ftp it somewhere?" Click here to view actual forum post


cPanel itself doesn't have an option to cron individual cPanel accounts.

This solution is based on information found on cpanel.net and looking at cPanel itself. It works by posting a request to cPanel to run the backup (so it can maintain the same method of backup as cpanel is upgraded). You could actually run this on any machine that has web access to your TCH host and PHP installed, you wouldn't necessarily need to run it on your account.


It is recommend that if you use this script, you at least minimally understand what it does.

This does contain passwords, so I recommend setting the permissions on this file to 600 and not placing this file within your public_html subdirectories. Use this script at your own risk!

Configuring CRON:

To run it as a cron job (at 3:30am like you wanted), put something in your crontab like the following (if the script is in your top directory):

30 3 * * * /usr/local/bin/php /home/youraccount/fullbackup.php

Downloading the script:

To download the script to your workstation, click here -> fullbackup.php

Modifying the script:

Name the script something like fullbackup.php and make sure to set all of the configuration variables). Make sure when you cut and paste it that the $data line remains one line (the if statement is the beginning of the next line).

The script includes SSL support. Although not so important if you run the script on the server you are generating the backup (besides, I don't believe the PHP on the TCH servers has SSL support compiled in)... the SSL support would be quite important if you decide to run this script somewhere else to connect to your TCH account.

Talk with us live about your problems!

Having a web hosting problem and need an answer now? Our web hosting support team is ready to answer your toughest account questions 24/7. Feel free to reach us if you are having a problem or just have a question or two about our services. We are here to help!