Exclude Files from Backups in cPanel - How to do it ?

In the process of setting up backups in cPanel, it is important to exclude certain files from Backups. For instance, if the user’s home directory stores backups generated by WordPress plugins, then, they need to be removed from the cPanel backup routine.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related WHM or cPanel queries.

In this context, we shall look into how to exclude certain files or folders from cPanel backup.

The need to Exclude Files from Backups in cPanel?

Recently, we received a support request where the customer was complaining that the cPanel backups. We noticed that customer had configured a WordPress plugin to generate a backup of the site. These backups were stored within user’s home directory.

Packaging these already compressed backups within another backup will not compress them further. However, it just inflates the size of the cPanel backup. Moreover, it consumes more disk space.

It is also important to exclude some files due to security reasons. Furthermore, error logs and other files not necessary for site restoration can also be excluded from the backup.

How to Exclude Files from Backups in cPanel ?

The exclude files can be set up in two different methods. We could either set up excludes for all users’ backups or for an individual user’s backups.

The global and local exclude files apply to the account backups that we manage in WHM's Backup section (WHM >> Home >> Backup) and the "Download a Full Website Backup" feature in cPanel’s Backup interface (cPanel >> Home >> Files >> Backup).

If we initiate a Home Directory Backup in cPanel's Backup interface (cPanel >> Home >> Files >> Backup), the global and local exclude files do not affect the contents of the backup file.

If we perform a backup with the /scripts/pkgacct script, the global and local exclude files do not affect the contents of the backup file.

The backup-exclude.conf files only apply to files or directories in a user's home directory. They do not apply to files or directories outside of a user's home directory.

Global exclude file

To exclude files or directories from backups for all user accounts, add those files or directories to the /etc/cpbackup-exclude.conf file. The /etc/cpbackup-exclude.conf file excludes the files that we specify relative to any location from which the backup script runs.

The backup system excludes the following files and directories for all users’ backups by default:


Local exclude file

To exclude files or directories from an individual user’s backups, add the desired paths (relative to the user’s home directory) to the cpbackup-exclude.conf file in the user's home directory, with one entry per line.

If the file does not already exist, we must create it. To do this, run the following command:

# touch /home/username/cpbackup-exclude.conf

In this example, username represents the name of the user who owns the files or directories.

If we enter a directory name, the backup system excludes all of the files that exist in the directory.

When we specify files, do not include leading or trailing characters of any kind, such as slashes (/) or periods (.).

For example, to exclude the /home/username/example/ directory and the /home/username/dir/example.php file from the username user’s backups, create the following /home/username/cpbackup-exclude.conf file:



[Need urgent assistance in performing cPanel backups? – We're available 24*7. ]


This article covers how to set up both global and local exclude files. Basically, we would require to exclude certain files from backups in cPanel either for security purposes or to reduce the size of the backup file. 

When backing up large accounts, it can be desirable to skip certain large directories or exclude files for security reasons. Whatever the reason, cPanel offers two methods for excluding files from the standard backup process.

To exclude files or directories from your user backups, perform either of the following actions:

  • Exclude the files from all user's backups.
  • Exclude the files from an individual user's backups.

For one cPanel user

Users or administrators can modify the user-level exclude file. /home/username/cpbackup-exclude.conf excludes files from a specific user's home directory.

$ nano /home/username/cpbackup-exclude.conf

# add new entries here