auto backup all /home/$user/public_html to /root/backup_home
yep another perl to make easy my job as sysadmin.
===========
#!/usr/bin/perl
#AutoBackup all /home/$user/public_html to /root/backup_home
#by: ev1lut10n - the sysadmin
#special thanks to : Merikenin
use POSIX;
sub utama()
{
eval
{
$uid=getuid();
if($uid ne "0")
{
print "[-] Sorry you gotta be root to run this tool !!!\n";
}
else
{
system("mkdir /root/backup_home");
viewhome();
}
}
}
sub viewhome
{
eval
{
open(PROSES_CACING, "ls /home |");
while (<PROSES_CACING>)
{
$tampilan = $_;
$tampilan =~ s/^\s+//;
$tampilan =~ s/\s+$//;
$cmd="cd /home/$tampilan/;tar czvf $tampilan.tgz public_html;mv $tampilan.tgz /root/backup_home";
system($cmd);
}
close(PROSES_CACING);
print "\n[+] Backup done !!! please check /root/backup_home !\n";
}
}
sub str_replace {
eval
{
my $replace_this = shift;
my $with_this = shift;
my $string = shift;
my $length = length($string);
my $target = length($replace_this);
for(my $i=0; $i<$length - $target + 1; $i++) {
if(substr($string,$i,$target) eq $replace_this) {
$string = substr($string,0,$i) . $with_this . substr($string,$i+$target);
return $string; #Comment this if you what a global replace
}
}
return $string;
}
}
utama();
=========
Home »Unlabelled » auto backup all /home/$user/public_html to /root/backup_home


{ 0 komentar... Views All / Send Comment! }
Posting Komentar