Excluding Installatron backups from DirectAdmin backups

Magistar

Verified User
Joined
May 31, 2014
Messages
86
I encourage my users to use Installatron to make an automatisch daily/weekly/monthly backup. These are placed in /application_backups in the user home folder. Unfortunately this means they get added to home.tar.gz inside the directadmin user/reseller/admin level backups. Basically I am making backup of backups. Today I saw a user bloat his backup file from 1 GB to over 7 GB, just because he kept a few backups.

I started asking Installatron if I could move this directory to /user_backups (since that is ignored by the backup system), but after a while they told me it was hardcoded.

Is there someway I can tell DA to ignore /application_backups just like it is ignoring /admin_backups and /user_backups ?
 
How about using this feature, paired with /etc/skel (to have the file exist for new users):

https://www.directadmin.com/features.php?id=1737

Finally found the nerve to try this and it works! After I did

Code:
echo "application_backups" >> .backup_exclude_paths
and
Code:
echo "allow_backup_exclude_path=1" >> /usr/local/directadmin/conf/directadmin.conf
The installatron folder is ignored as is the desired result. On my test backup the tar went from 1200 MB to 400 MB :).

Still need to figure out how to enable it by default. How about adding this to /usr/local/directadmin/scripts/custom/.user_create_post.sh ?

Code:
#!/bin/sh
 if [ "$spam" = "ON" ]; then
    DIR=/home/$username/.spamassassin
    mkdir  $DIR
    touch $DIR/user_prefs             #or this is where you'd copy  the default user_prefs you want them to have, instead of "touch".
    chown  ${username}:mail $DIR
    chmod 771 $DIR
    chown $username:$username  $DIR/user_prefs
    chmod 755 $DIR/user_prefs
    touch $DIR/spam
    chown  mail:$username $DIR/spam
    chmod 660 $DIR/spam
 fi
 exit 0;
 DIR=/home/$username
 echo "application_backups" >> $DIR/.backup_exclude_paths

disclaimer: Not that experienced with sh
 
Seems to me this won't work because you placed it behind the "exit 0;"

Try it like this:
Code:
#!/bin/sh
 if [ "$spam" = "ON" ]; then
    DIR=/home/$username/.spamassassin
    mkdir  $DIR
    touch $DIR/user_prefs             #or this is where you'd copy  the default user_prefs you want them to have, instead of "touch".
    chown  ${username}:mail $DIR
    chmod 771 $DIR
    chown $username:$username  $DIR/user_prefs
    chmod 755 $DIR/user_prefs
    touch $DIR/spam
    chown  mail:$username $DIR/spam
    chmod 660 $DIR/spam
 fi
DIR=/home/$username
touch $DIR/.backup_exclude_paths
echo "application_backups" >> $DIR/.backup_exclude_paths
exit 0;
Disclaimer: I'm not that experienced in sh either.
I added the "touch" line in case the .backup_exclude_paths file does not exist, just like this example the user_prefs is created also.
Hope it's correct.

If you find a way to enable it by default or to add it for all current users that would be great.
 
I'd probably do it like this, so it's a bit more surgical:
Code:
#!/bin/sh
HOMEDIR=/home/$username
if [ ! -d $HOMEDIR ]; then
    echo "Cannot find $HOMEDIR"
    exit 1;
fi


if [ "$spam" = "ON" ]; then
    DIR=$HOMEDIR/.spamassassin
    mkdir  $DIR
    touch $DIR/user_prefs             #or this is where you'd copy  the default user_prefs you want them to have, instead of "touch".
    chown  ${username}:mail $DIR
    chmod 771 $DIR
    chown $username:$username  $DIR/user_prefs
    chmod 755 $DIR/user_prefs
    touch $DIR/spam
    chown  mail:$username $DIR/spam
    chmod 660 $DIR/spam
fi


BEP=$HOMEDIR/.backup_exclude_paths
if [ ! -e $BEP ]; then
    echo "application_backups" > $BEP
    chown $username:$username $BEP
else
    C=`grep -c '^application_backups$' $BEP`
    if [ "$C" = "0" ]; then
        echo "application_backups" >> $BEP
    fi    
fi

AB=$HOMEDIR/application_backups
if [ ! -d $AB ]; then
	mkdir $AB
	chown $username:$username $AB
fi


exit 0;
AND so that you can run it for each existing User:
Code:
#!/bin/sh
for i in `ls /usr/local/directadmin/data/users`; do
{
    username=$i spam=OFF /usr/local/directadmin/scripts/custom/user_create_post.sh
};
done;
exit 0;
Note, both of the above scripts are not tested, but that's the basic idea.

John
 
Why not use:

echo "application_backups" >> /usr/local/directadmin/data/admin/skip_backup_home_files.list
chown diradmin: /usr/local/directadmin/data/admin/skip_backup_home_files.list

This case the application_backups directory is ignored for all users (server-wide). We use it this way.
 
Back
Top