Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Do Not Backup Users tmp When Using /scripts/cpbackup

Discussion in 'Data Protection' started by emericklaw, Sep 20, 2005.

  1. emericklaw

    emericklaw Active Member

    Joined:
    Mar 31, 2005
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    151
    Is there a way to stop the backup from backing up the /home/USER/tmp folder?

    It greatly increases the size of the backup because it is backing up the awstats/analog etc temporary files. My backups are transfered via FTP to a remote server and by cutting out the users tmp would reduce the time taken and traffic used.

    Would it just be a case of modifying the 'tar' part of the script and using the -X option to exclude tmp.

    Thanks
     
  2. linux-image

    linux-image Well-Known Member

    Joined:
    Jun 8, 2004
    Messages:
    1,191
    Likes Received:
    1
    Trophy Points:
    168
    Location:
    India
    cPanel Access Level:
    Root Administrator
    if you know to shell script, you can opt to edit the script to move the tmp directory before the backup is taken and then move it back after the tar is done.
     
  3. emericklaw

    emericklaw Active Member

    Joined:
    Mar 31, 2005
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    151
    Well I had a longer dig around and managed to do it.

    I didn't use the tar -X method though.

    The cpbackup script calls another script, pkgacct and in there there is a function called safesync. This has an excludes part to it which excludes files/directories based on a regular expression.

    On about line 600 you should find:

    Code:
       if ($isuserbackup) {
          %NFL = safesync(user=>$user,
                gidlist=>["cpanel","nobody"],
                source=>"${homedir}/",
                dest=>"${tarroot}/${prefix}${user}/homedir",
                chown=>0,
                exclude=>'/backup-[^\_]+_[^\-]+-[^\-]+-[^\_]+_' . ${user});
       } else {
          %NFL = safesync(user=>$user,
                gidlist=>["cpanel","nobody"],
                source=>"${homedir}/",
                dest=>"${tarroot}/${prefix}${user}/homedir",
                chown=>0,
                delete=>1,
                verbose=>0);
       }
    The first part of the if statement is used when users request a manual backup through cpanel and it excludes all backup-DATE_TIME_USER.tar.gz files from being backed up.

    The second part of the if statement is used for all other backups so an exclude needs to be added. I wanted it to exclude all backup-DATE_TIME_USER.tar.gz and the contents of the users tmp directory in their homedir.

    This is the code I now use:

    Code:
       if ($isuserbackup) {
          %NFL = safesync(user=>$user,
                gidlist=>["cpanel","nobody"],
                source=>"${homedir}/",
                dest=>"${tarroot}/${prefix}${user}/homedir",
                chown=>0,
                exclude=>'/backup-[^\_]+_[^\-]+-[^\-]+-[^\_]+_' . ${user});
       } else {
          %NFL = safesync(user=>$user,
                gidlist=>["cpanel","nobody"],
                source=>"${homedir}/",
                dest=>"${tarroot}/${prefix}${user}/homedir",
                chown=>0,
                delete=>1,
                exclude=>'/(backup-[^\_]+_[^\-]+-[^\-]+-[^\_]+_' . ${user} . '|tmp/[^\_])',
                verbose=>0);
       }
    If you wanted to only exclude files in the tmp directory then change: '/(backup-[^\_]+_[^\-]+-[^\-]+-[^\_]+_' . ${user} . '|tmp/[^\_])' TO '/tmp/[^\_]'

    Just this change has reduced my daily backup by 350MB!

    I am also thinking about excluding mp3s from backups too. A few of my users host their own bands material so quite a big reduction could be made there too.
     
Loading...

Share This Page