KNOWNHOST WIKI

User Tools

Site Tools


control-panels:misc:how-to-excluede-certain-content-from-backups

Stop Taking Backups of Backups and Save Disk Space via Backup Exclusions


cPanel

We've noticed unnecessarily large cPanel backups and often times, the reason is due to customers inadvertently taking backups of other backups that are stored within the cPanel user's home directory (e.g., Wordpress plugin backup solutions, Softaculous backups, etc.). These backups are already compressed and packaging them within another backup is not going to compress them further. It is only going to inflate the size of the cPanel backup by the size of the included backup, and thus, consume more disk space. If you want backups of backups, then by all means, do so, but if you want to only archive site files and do want to exclude backups files, error logs, and other files not necessary for site restoration, then you will want to proceed with the following article.

You have two different options for defining these files to exclude from backups:

  1. You can exclude the file from a single cPanel user's backups, or
  2. You can exclude the files from all cPanel users' backups.

Note: The backups exclusions do not apply to backups made with the /scripts/pkgacct script not those created when using the Home Directory backup in cPanel's Backup interface (cPanel » Home » Files » Backup). These exclusions only apply to backups made via WHM's Backup section (WHM » Home » Backup) and the Download a Full Website Backup feature in cPanel's Backup interface (cPanel » Home » Files » Backup).

Let's say that you have many cPanel users that keep Softaculous backups, and you would like to exclude Softaculous backups from all cPanel users' backups. To do so, you would edit the global backup exclusion file, located at /etc/cpbackup-exclude.conf and add "softaculous_backups/*" to the file and save. The end result may look like this:

  [root@host ~]# cat /etc/cpbackup-exclude.conf
  .MirrorSearch
  .cpan
  .cpanel/datastore
  .cpanel/caches
  .cpcpan
  */.wysiwygPro_*
  */core.[0-9]*
  access-logs
  public_ftp/.ftpquota
  .sqmailattach
  lscache/
  softaculous_backups/*

Note that the path you specify is relative to the user's home directory, so the full Softaculous backup path is

  /home/$USER/softaculous_backups/backup.tar.gz

Now, let's say that you have a single user that uses a certain Wordpress backup plugin (we will use Updraft in this example), and you would like to exclude their custom backups from only their cPanel backups. To do so, you would edit that user's backups exclusion file located at

  /home/$USER/cpbackup-exclude.conf

If that file doesn't exist, you can create it like so:

  touch /home/$USER/cpbackup-exclude.conf
  chown $USER. /home/$USER/cpbackup-exclude.conf

Again, the path you enter into the file is a relative path that starts at the user's root directory (/home/$USER/), so for Updraft backups, you would add the following entry:

  [root@host ~]# cat /home/$USER/cpbackup-exclude.conf
  */wp-content/updraft/*
  [root@host ~]#

The reason we chose to use '*/wp-content/updraft/*' instead of 'public_html/wp-content/updraft/*' is so that subdomains that are created above the public_html and use the same backup system are accounted for. If you only use the backup system for the main domain, then you can use this:

  [root@host ~]# cat /home/$USER/cpbackup-exclude.conf
  public_html/wp-content/updraft/*
  [root@host ~]#

Another example file that many may want to exclude would be PHP error logs. If you were to exclude these from all cPanel backups, you could add it to the global cPanel exlude configuration file using the following command:

  echo '*/error_log' >> /etc/cpbackup-exclude.conf

This will exclude PHP error_log files that are set in the sites' document roots for all domains and subdomains.

Using the cPanel backup exclusions wisely can help you to save disk space. Knownhost is here 24/7 if you have any questions!


DirectAdmin

DirectAdmin also offers this feature to prevent your backups from being unnecessarily large.

The configuration file is located here:

  /home/$USER/.backup_exclude_paths

The format of the file must be relative to /home/$USER and should not include a "/home/$USER" prefix just as was discussed above with the cPanel backup exclusions.

  [root@host custombuild]# /usr/local/directadmin/directadmin c | grep skip
  skip_hometargz_in_backups=0
  skip_domains_in_backups=0
  skip_imap_in_backups=0
  skip_uebimiau_in_backups=0
  skip_roundcube_in_backups=0
  skip_databases_in_backups=0
  skip_ftp_on_backup_fail=0
  [root@host custombuild]# 

Note: that this feature requires the following setting to be set in the DirectAdmin configuration, which is indeed set by default for newer versions:

  allow_backup_exclude_path=1

You can use the following command to check and confirm that this is set:

  /usr/local/directadmin/directadmin c | grep allow_backup_exclude_path

So, let's say that you need to exclude Awstats data from your backups, which is located at /home/$USER/domains/domain.com/awstats. You can do so with the following to exclude all domains Awstats data for the user:

  echo "domains/*/awstats" >> /home/$USER/.backup_exclude_paths
  chown $USER. /home/$USER/.backup_exclude_paths

A handy feature of the DirectAdmin backup system is that you can exclude all files of a particular type or extension. For example, you can add the following to the .backup_exclude_paths file in order to exclude all .tar, .gz, and .zip files from your backups:

  *.gz
  *.tar
  *.zip

The path to the files do not matter as the * encompasses as possibilities.

In addition to the user-configurable backup exclusions, DirectAdmin also allows you to skip certain content in backups on the global level, though it isn't as customizable.

Here are the options, and they are each self-explanatory:

  [root@host custombuild]# /usr/local/directadmin/directadmin c | grep skip | grep -v fail
  skip_hometargz_in_backups=0
  skip_domains_in_backups=0
  skip_imap_in_backups=0
  skip_uebimiau_in_backups=0
  skip_roundcube_in_backups=0
  skip_databases_in_backups=0
  [root@host custombuild]# 

If you'd like to enable any of these, set them to 1 in

  /usr/local/directadmin/custombuild/options.conf

and restart DirectAdmin using the following command:

  service directadmin restart
control-panels/misc/how-to-excluede-certain-content-from-backups.txt · Last modified: 2020/06/01 10:51 by Karson N.