备份几台服务器的/home分区

| 暂无评论 | 暂无引用通告

-->

备份几台服务器的/home分区并将备份文件传到备份主机上:

其实就是执行个命令:

dump 0uf host.date.dump /home 

#!/usr/bin/perl -w

use strict;



$/='';

my %data;

while(<DATA>){

chomp $_;

my ($host,$dir)=split /\n/;

$data{$host}=$dir;

}

my $backuphost="backuphost";

my $backup="/backup";

my $host=shift;


my $backuptype=shift;


my $dir_backup=$data{$host};


my $time=localtime;

my @timetur=split / /,$time;

$time=join '-',@timetur[4,1,2,0];


my $archive=$host.".".$time.$backuptype.".dump";


$backuptype=$backuptype."uf";


print "待备份主机:$host\n";

print "备份类型:$backuptype\n";

print "待备份目录:$dir_backup\n";

print "生成的文件:$archive\n";

print "现在开始备份.....\n";

`ssh $host "rm -rf $host.*;dump $backuptype $archive $dir_backup"`;

if($?){

print "备份失败\n";

}else{

print "备份完成\n";

}

print "复制到备份主机$backuphost:$backup.....\n";

`scp $host:$archive $backuphost:$backup`;

if($?){

print "复制备份失败\n";

}else{

print "复制备份完成\n";

}

__DATA__

web

/home


jt

/home


nsp

/home


运行脚本:

[root@supersun script]# perl backuppar.pl jt 0

待备份主机:jt

备份类型:0uf

待备份目录:/home

生成的文件:jt.2007-Aug-31-Fri0.dump

现在开始备份.....

DUMP: Date of this level 0 dump: Fri Aug 31 17:05:53 2007

DUMP: Dumping /dev/cciss/c0d0p6 (/home) to jt.2007-Aug-31-Fri0.dump

DUMP: Added inode 8 to exclude list (journal inode)

DUMP: Added inode 7 to exclude list (resize inode)

DUMP: Label: /home

DUMP: mapping (Pass I) [regular files]

DUMP: mapping (Pass II) [directories]

DUMP: estimated 611523 tape blocks.

DUMP: Volume 1 started with block 1 at: Fri Aug 31 17:06:05 2007

DUMP: dumping (Pass III) [directories]

DUMP: dumping (Pass IV) [regular files]

DUMP: Closing jt.2007-Aug-31-Fri0.dump

DUMP: Volume 1 completed at: Fri Aug 31 17:06:32 2007

DUMP: Volume 1 626200 tape blocks (611.52MB)

DUMP: Volume 1 took 0:00:27

DUMP: Volume 1 transfer rate: 23192 kB/s

DUMP: 626200 tape blocks (611.52MB) on 1 volume(s)

DUMP: finished in 27 seconds, throughput 23192 kBytes/sec

DUMP: Date of this level 0 dump: Fri Aug 31 17:05:53 2007

DUMP: Date this dump completed: Fri Aug 31 17:06:32 2007

DUMP: Average transfer rate: 23192 kB/s

DUMP: DUMP IS DONE

备份完成

复制到备份主机backuphost:/backup.....

Connection to jt closed.

复制备份完成

[root@supersun script]#


暂无引用通告

发送引用通告网址: http://supersun.info/mt/mt-tb.cgi/696
如果您想引用这篇日记到您的Blog,请复制上面的链接,放置到您发表文章时的相应界面中。

发表评论

最新资源

  • IMG_1437.JPG
  • line.png
  • bar.png
  • perl_calander.jpg

关于此日记

此日记由 supersun 发表于 2007年8月31日 17:12

此Blog上的上一篇日记map和grep

此Blog上的下一篇日记网页尺寸的界定

首页归档页可以看到最新的日记和所有日记。