Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Apr 2003
    Posts
    168
    cPanel/Enkompass Access Level

    Root Administrator

    Default [Script] Give Resellers access to their client's backups

    Treat your resellers and give them access to their end-user backups!

    Not only will it give them full control over their client's backups, it will also allow them to restore individual files - giving them the ability to more accurately assist their own clients on simply restoration requests.

    The script pulls the backup type (incremental or non-incremental) and also pulls the backup destination. If you are using cPanel's backup system and backing up to secondary - this is the script for you.

    Below is a sample output of the script in action. You can ofcourse set this script to run on a weekly basis to update symlinks.

    If you're running this as a cronjob, be sure to suppress the output with 1> /dev/null
    ie. ~/root/symbackups.pl 1> /dev/null

    root@pluto [~]# ./symbackups.pl
    cpbackup set to incremental
    cpbackup dir set to /backup/cpbackup

    processing daily backups
    ..........................................................................................................................
    ..........................................................................................................................
    ..........................................................................................................................
    ..........................................................................................................................
    .....................................
    processing weekly backups
    ..........................................................................................................................
    ..........................................................................................................................
    ..........................................................................................................................
    .........................................................................................................................
    ......................................
    /backup/cpbackup/monthly does not exist!

    cPanel backup symlink procedure completed in: 373 seconds
    Here is the script. Simply Copy/Paste, Chmod and Execute.

    Code:
    #!/usr/bin/perl
    
    chdir("/var/cpanel/users");
    
    my @backups = ("daily","weekly","monthly");
    my $backupdir = `grep BACKUPDIR /etc/cpbackup.conf`;
    my $backuptype = `grep BACKUPINC /etc/cpbackup.conf`;
    
    chomp($backuptype);
    chomp($backupdir);
    
    (undef,$backupdir) = split(/ /,$backupdir);
    (undef,$backuptype) = split(/ /,$backuptype);
    
    my $start_time = time();
    
    if ($backuptype eq "yes") { print "cpbackup set to incremental\n"; $backupinc = 1; }
    elsif ($backuptype eq "no") { print "cpbackup set to non-incremental\n"; $backupinc = 0; }
    else { print "cpbackup not configured!\n"; exit; }
    
    $backupdir .= "/cpbackup";
    print "cpbackup dir set to $backupdir\n";
    
    foreach $backupint (@backups) {
     if (-d "$backupdir/$backupint") { &symbackups(); }
     else { print "$backupdir/$backupint does not exist!\n"; }
    }
    
    my $end_time = time();
    my $runtime = $end_time - $start_time;
    
    print "\ncPanel backup symlink procedure completed in: $runtime seconds\n";
    
    exit;
    
    sub symbackups() {
     print "\nprocessing $backupint backups\n";
    
     open(LIST,"ls -1 |");
      foreach $username (<LIST>) {
       chomp($username);
       $userowner = `grep OWNER $username | cut -d= -f2`;
       chomp($userowner);
       print ".";
       system("mkdir /home/$userowner/backups 2> /dev/null");
       system("chown $userowner:$userowner /home/$userowner/backups 2> /dev/null");
       system("mkdir /home/$userowner/backups/$backupint 2> /dev/null");
       system("chown $userowner:$userowner /home/$userowner/backups/$backupint 2> /dev/null");
    
       if ($backupinc == 1) {
        system("ln -s /backup/cpbackup/$backupint/$username /home/$userowner/backups/$backupint/$username 2> /dev/null");
        system("chown -R :$userowner /backup/cpbackup/$backupint/$username 2> /dev/null");
        system("chmod -R 775 /backup/cpbackup/$backupint/$username 2> /dev/null");
       }
       else {
        system("ln -s /backup/cpbackup/$backupint/$username.tar.gz /home/$userowner/backups/$backupint/$username.tar.gz 2> /dev/null");
        system("chown :$userowner /backup/cpbackup/$backupint/$username.tar.gz 2> /dev/null");
        system("chmod 775 /backup/cpbackup/$backupint/$username.tar.gz 2> /dev/null");
       }
      close(LIST);
     }
    }
    Spot a bug? Let me know! Thanks. I hope this script works out as well
    Dylan Botha

  2. #2
    Member rhenderson's Avatar
    Join Date
    Apr 2005
    Location
    Oklahoma
    Posts
    742

    Default

    Looks like a nice script. Question: Will the linked files count towards the resellers quota?
    Regards,
    Randy
    Affordable Web Hosting
    _________________________

  3. #3
    Member
    Join Date
    Apr 2003
    Posts
    168
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by rhenderson View Post
    Looks like a nice script. Question: Will the linked files count towards the resellers quota?
    Nope. It won't.
    Dylan Botha

Similar Threads & Tags
Similar threads

  1. Reseller: How do I give a client Bandwith From WHM ?!!
    By dj_haselking in forum New User Questions
    Replies: 1
    Last Post: 02-06-2010, 12:25 PM
  2. Resellers Can't give IP adress their customers.
    By zinehost in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 04-15-2006, 10:35 PM
  3. Why can't we give resellers backup access?
    By Insyder in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 05-10-2004, 11:46 PM
  4. How to give resellers there own nameservers?
    By AbeFroman in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 10-04-2002, 09:26 AM
  5. What features do I give resellers?
    By fjiwa in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 07-25-2002, 04:23 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube