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
Here is the script. Simply Copy/Paste, Chmod and Execute.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
Spot a bug? Let me know! Thanks. I hope this script works out as wellCode:#!/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); } }



LinkBack URL
About LinkBacks


Reply With Quote





