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








Generally, When backing up large accounts, it can be desirable to skip certain large directories or exclude files for security reasons.

Sometimes, we notice that large backups and often times, the reason is due to customers inadvertently taking backups of other backups that are stored within the user's home directory

For example, WordPress plugin backup solutions, Softaculous backups, etc.

It should be noted that It is only going to inflate the size of the backup by the size of the included backup, and thus, consume more disk space.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related DirectAdmin control panel queries.

In this context, we shall look into how to archive site files and to exclude backups files, error logs and other files not necessary for site restoration.


How to Exclude Files from Backups in DirectAdmin ?

DirectAdmin offers the feature to prevent backups from being unnecessarily large.

Usually, path for configuration file is:

/home/$USER/.backup_exclude_paths

The format of the file must be relative to /home/$USER and should not include a "/home/$USER" prefix.

[root@server]# /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@server]#

The following setting to be set in the DirectAdmin configuration, which is indeed set by default for newer versions:

allow_backup_exclude_path=1

The following command to check and confirm that this is set:

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

In order to, exclude Awstats data from backups, which is located at /home/$USER/domains/domain.com/awstats

We 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 we can exclude all files of a particular type or extension. 

For example, we can add the following to the .backup_exclude_paths file in order to exclude all .tar, .gz and .zip files from our backups:

*.gz
*.tar
*.zip

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

DirectAdmin also allows to skip certain content in backups on the global level, though it is not as customizable.

Here are the options:

[root@server]# /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@server]#

If we 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


[Need support in fixing DirectAdmin errors? We can help you. ]



Conclusion

This article covers how to Exclude Files from Backups in DirectAdmin. 


User ability to skip paths from their tar.gz backup files in DirectAdmin.

i. New optional file:

/home/username/.backup_exclude_paths

where User can add paths to this file that they wish to have skipped from their backup.

The format of the file must be relative to /home/user and should not include a "/home/user" prefix.

2. New default internal directadmin.conf setting:

allow_backup_exclude_path=1

can be disabled by setting it to 0 and restarting DA.

A sample line in the .backup_exclude_paths would look like:

domains/domain.com/awstats

so that the path:

/home/username/domains/domain.com/awstats

is skipped from the backup.

This will add:

--exclude-from=/home/username/.backup_exclude_paths

Just after the -C /home/username option in the creation of BOTH the home.tar.gz and the user's backup tar.gz.

So using the feature will truly exclude the path, regardless of if it's in /home/user/domains, or /home/user/*.

As you may have noticed, the option uses tar's exclude-file option.

This supports patterns, eg:

*.gz

So you have skip those types of files, regardless of what path they're under.


For Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on LinuxAPT.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com