Linux下的各种备份方法汇总

资讯 驱动中国 3,367 次阅读 0 条评论
分享 Q

一.在单个服务器上的备份
最常见的备份方法是在命令行上用经典的备份程序tar.是最通用最简单也最有用的备份工具
#tarcvfbackup.tar/etc(备份整个etc目录及下面的所有子目录和文件)
#gzip-9backup.tar(得到最大的压缩率)

你可以把备份后的backup.tar.gz转存到其它介质,CDR/CDRW光盘,私人信箱等

二.跨服务器的备份
1.利用ssh/scp功能直接把文件或目录从一台服务器拷贝到另一台服务器上。
参见文章荟萃中另一篇文章《如何不用密码进行ssh/scp》
2.利用smbmount先mount另一台服务器上的Samba共享目录到这台机器的某目录下,直接进行cp操作。
如:[root@sh/mnt]#smbmount//sh3/pub/mnt/sh3-N
将服务器sh3上的Samba共享目录pubmount到服务器sh上的/mnt/sh3目录下面。且不提示密码
3.利用NFS功能进行服务器间的备份,有一定程序的安全性问题,在此不多做介绍。

三.备份到其它介质
你可以备份到磁带,ZIPdrive,JAZdrive
1.备份到磁带
假设你已经设置并安装好了磁带机,本人用的是HPSuitStore500,外置,SCSI接口。
1.查看磁带中的目录tartvf/dev/st0
2.查看磁带内容并输出到一个文件中tartvf/dev/st0>stlist
3.备份档案tarcvf/dev/st0/etc
tarcvf/dev/st0/etc/hosts/boot/etc/smb.conf
4.按指定的文件内容或目录释放出磁带中的相应文件
tar-Tstlist-xvf/dev/st0
tarxvfz/dev/st0/etc/
6.附加个别文件到磁带后面
tar-r/etc/hosts/etc/passwd-vf/dev/st0
7.从现有磁带中删除一个或几个文件
tar--deleteetc/hosts-vf/dev/st0
8.附加一个现有的tar文档到磁带后面
tar-Apamd.tar-vf/dev/st0
2.备份到JAZ驱动器
7.3GettingaZipdrivetowork
(参见RedhatFAQ:http://www.redhat.com/support/docs/faqs/rhl_general_faq/FAQ.html)
ThereareexcellentreferencesintheZIPHOWTOsathttp://www.redhat.com/mirrors/LDP.

Also,thereisaZipHOWTOat:

http://www.linuxdoc.org/HOWTO/HOWTO-INDEX-3.html

InRedHatLinux6.1,thereareafewextrastepsneededtogetaparallelportZipdrivetowork:

Edityour/etc/conf.modulesandadd:

aliasparport_lowlevelparport_pc
aliasscsi_hostadapterppa

Thenloginasrootandrun:
modprobeppa

SomepeoplehavehadproblemsiftheydaisychainaZipdriveoffofachainwitha
printeronit.Currently,werecommendthatyouuseeithertheprinterortheZipdrive.

Formoreinformation,checkwww.torque.net/paraport

IfyouarehavingproblemswithanIDEZipdrive,hereisfurtherinformation:

Firstcheckandmakesurethereisadiskinthedrive.Also,makesureyouaremounting
itaspartition4insteadof1.Anexamplewouldbehdc4.Thereasonforthisisthat
theMacintoshusespartition4foritsdatapartitionandhasproblemsifdataison
anotherpartition.

3备份到JAZ驱动器
假定JAQ驱动器为SCSI接口,把JAZ驱动器当作SCSI链上的一个存储设备即可。
四.跨操作系统进行备份
1.把Linux服务器上的数据资料备份到windows95/98机器上
假定一台windows机器jephe有一完全读写共享目录data,且密码为secret,现希望把Linux上的
文件备份到这个共享目录下,则先把这个共享可写目录mount到Linux下,再做普通的cp操作

附:在Linux上对Novell服务器上的数据进行备份:(http://www.pcquest.com/linux/netware.asp)
NetWareAndLinux

MakingyourLinuxservertalktoNetWareserversandprinters

Asalmosteveryoffice-LANhasaNetWareserver,yourdesktopclientmustbeabletotalk
toNetWare.ThisarticletellsyouhowaLinuxboxcanaccessfilesonaNovellserver
andprinttoaNovellprintqueue.

Linux,bydefault,usestheIPnetworkprotocolfornetworkcommunication.However,Novell
NetWareusestheIPXnetworkprotocol.AstheLinuxkernelhasacompletelynewnetwork
implementationcomparedtootheroperatingsystemslikeUnix,itsupportsarangeof
non-TCP/IPprotocolsincludingtheIPXprotocol.Kernels2.xonwardshavebuilt-inIPX
support.TheRedHatLinuxdistributedonourCD-ROMhasittoo.TheLinuxkernelsupports
theIPXprotocolonly.Itdoesnot,yet,supportprotocolssuchasIPX/RIP,SAP,orNCP.

ThefirststepistoconfigureyourIPXinterfaces.

Loginasroot
Typeipx_configure--auto_primary=on--auto_interface=on
Waitforaminuteandtypecat/proc/net/ipx_interface.Youshouldseesomethinglike:
NetworkNode_AddressPrimaryDeviceFrame_Type
000000E100A0C925164AYeseth0802.2

4.Typeslist.YoushouldseealistoftheNetWareserversonyourLAN.

KnownNetWareFileServersNetworkNodeAddress
D74_SERVER00000D7400000000001

Ifyoudon't,waitforafewminutesandretry.Iftheslistcommanddisplaysamessage
like:ncp_connect:Invalidargument,thenyourkernelprobablydoesnotsupportIPX.
Checkthatyouhaveactuallybootedofftheappropriatekernel.Whenyoubootyoushould
seemessagesaboutIPXandncpfsinsystemstartupmessages.Iftheslistcommanddoes
notlistallofyourfileservers,thenyoumayneedtousethemanualnetworkconfiguration
method.Typecat/proc/net/ipx_interface.Youshouldseesomethinglike:

Atthispoint,yourLinuxboxissetupforIPXnetworking.Checkifyourkernelhas
supportforNetWareNCPfilesystem.ThedefaultRedHatkernelhasNCPfilesystem
support.Yousimplyhavetoloadthencpfsmodule/usr/sbin/lib/modules/2.0.32/fs/ncpfs.0.
Youcanalsoaddthelinetoyourlocalfiletoloaditautomaticallyattheboottime.

Oncethatisdone,

Loginasroot(onlyrootcanmountNetWarevolumes).
Typemkdir/netwaretocreateadirectoryformountingtheNetWarevolumes.
Typencpmount-SD74_SERVER-Uuser10/netware.Youwillbepromptedforapasswordforuser10.
Atthispointyourserverismountedon/netware.Thevolumesaresub-directoriesunder
/netware.SotheSYSvolumewouldbe/netware/sysandtheDATAvolumewouldbe/netware/data.
Ifyouonlywanttomountasinglevolume,youcanusencpmount-SD74_SERVER-Vsys-Uuser10
/netware.ThiswillmountonlytheSYSvolumeto/netware.
WhenyoufinishusingtheNet-Warevolume,youcanunmountusingncpumount/netware.
Tip:Youdon'tneedtomanuallyunmountNetWarevolumeswhenyoushutdown.
WhenyouwanttosharethemountedNetWarevolumeamongotherLinuxusers,youneedto
understandfilepermissions.TheNetWarefilesystemdoesn'tsupportuserIDsandgroup
IDsfordirectories.Soallfilesanddirectoriesonthemounteddirectoryhavethe
permissionsasthedirectorywhereitwasmounted.Forexample,ifyoutypels-ld/netware,
drwxrwxr-x1rootroot512Nov241960/netwareiswhatyouget.

So,alltheNetWarefileswillhavetheabovefilepermissions.

Ifyouwantnon-rootuserstomountNetWarevolumes,ncpmountcommandmustbeSetUseridRoot,
soyouwouldneedtotypechmod4755ncpmount

Simplifyingmountingofvolumes

ThereisanotherwayofconfiguringNetWaremounts-bycreatinga.nwclientfileinyourhome
directory.ThisfilecontainsdetailsoftemporaryoruserspecificNetWaremountsthatwould
beperformedregularly.Itallowsyoutostorethedetailsofmountssothatyoucanrecreate
themwithoutspecifyingalldetailseachtime.Itsformatisquitestraightforward:

#Thefirstentryisthe'preferredserver'entryandis
#usedwheneveryoudonotspecifyaserverexplicitly.
#
#UserUSER01logintoD74_SERVERfileserverwithpassword'password'D74_SERVER/USER01password
#
#UserCYBERlogintotheCYBER_DOCfileserverwithnopassword.
CYBER_DOC/CYBER-

Toactivatethesemountsyoutypencpmount/netwaretomountD74_SERVERwithalogin(say)TERRY
under/NetWaredirectory.Notethatthisentrywaschosenbecausenofileserverwasspecified
inthemountcommand.Hadweusedncpmount-SCYBER_DOC/netware,thenitwouldmountCYBER_DOC
withaloginofCYBERunder/NetWaredirectory.

SincethepasswordsforyourNovellaccountsarenotencrypted,youshouldprotectthemby
typingchmod0600$HOME/.nwclient.

PrintingtoNetWareprintqueues

Onceyouarecomfortableaccessingyourfiles,youcantryprintingtoaNovellprintqueue.

UseslisttocheckthatyoucanseeyourNovellserver.
Typepqlist-SD74_SERVER-UUSER01tolisttheprintqueuesonD74_SERVER.
Typenprint-SD74_SERVER-UUSER01-qDMPQUEUE/etc/passwd.Thiswouldprintthe/etc/passwd
filetotheDMPQUEUEprintqueueontheD74_SERVERbylogginginasUSER01.Ifyouhavecreated
your.nwclientfile,thenyoucanusenprint-qDMPQUEUE/etc/passwdinstead.Theserverand
loginIDaretakenfromthe.nwclientfile.Ensurethatthequeuenamesareincapitals.
CheckyourNovellprintqueuefromaDOSclientusingPCONSOLE.Youshouldseeaprintjob
calledNoDescriptionintheDMPQUEUE.
Printingusingnprintistedious-firstitrequiresyoutoprinttoafileandthensubmit
usingnprint.YoucanautomatethisbysettingupaLinuxprintqueue,whichautomatically
sendsittotheNetWareprintqueue.Thefollowingstepsareabitconfusingandreading
aboutUnixprintinginthePrintingHOW-TOwouldbebeneficial.

ThefollowingstepstellyouhowtoconfigureaNetWareprintqueueforRedHatLinux.

CopyNetwareprint.tgzfromtheCD-ROMtothe/tmpdirectory.
cd/;tarxzvf/tmp/netwareprint.tgz.Thiswillreplace/usr/bin/printtool,
/usr/lib/rhs/rhs-printfilters/master-filter,and/usr/lib/rhs/rhs-printfilters/nwprint,
withthelatestversions.
Ifyouaren'talreadyinXWindows,startbytypingstartx.
Ifthegraphicalcontrolpanelisnotvisible,startitbytypingcontrol-panel&inanXTerm.
Clicktheprintericoninthecontrolpanel.Youshouldseealistofprinterscurrently
configuredforLinux.
ClickAdd.Adialogboxwithvarioussupportedprintqueuesappears.SelectNovell
Netwareprintqueue.
InPrintername,enternwqueue.
EnterD74_SERVERandDMPQUEUEfortheNetWareserverandprintqueue.Ensurethatthequeue
namesareincapitals.
Entertheusernameandpasswordifneeded.Ifyouhaveapassword,youmustenterithere
becauseitwillnotpromptyouforapasswordduringprinting.
Inthefiltertype,selecttheappropriateprintertype.Ifyourlaserprintersupports
postscriptprinting,pleaseusePostscriptprinter.
ClickOKandyou'llseeanewprintercallednwqueueinthelistofprinters.
SelectnwqueuefromthelistandclickTestPrintfromthemenu.UseaDOSclientwith
PCONSOLEtochecktheDMPQUEUE.Youshouldseeanewprintjobinthequeue.Incaseit
doesn'twork,trymountingavolumefromtheserverD74_SERVER(onwhichtheprintqueueresides).
Nowyourprintingshouldbeset-up.Toprint/etc
/passwd,typelpr-Pnwqueue/etc/passwdatyourprompt.
ToprintfromNetscape,usethecommandlpr-Pnwqueuetoprint.Alternatively,you
couldalwaysprinttoafileandusenprinttoprintitmanually.
Utilitycommands

RecentversionsofVolker'sncpfspackageincludearangeofuserandadministration
commands.Thetoolsarebuiltandinstalledaspartofthencpfsinstallationprocess.
Thougheachhasadetailedmanualpage,hereisasummaryofeachfromtheIPX-HOWTO.

ncopy(NetworkCopy):AllowsefficientfilecopyingusingaNetWarefunctionrather
thanacopyacrossthenetwork.
nsend(NetworkSend):AllowsyoutosendmessagestootherusersonaNetWareserver.
nwbols(ListBinderyObjects):AllowsyoutolistthebinderycontentsofaNetWareserver.
nwboprops(ListPropertiesofaBinderyObject):Allowsyoutoviewthepropertiesofa
NetWarebinderyobject.
nwfsinfo(FileserverInformation):PrintssummaryinformationaboutNetWareserver.
nwpasswd(NetWarePassword):AllowsyoutochangeNetWareuserspassword.
nwrights(NetWareRights):Displaystherightsassociatedwithaparticularfileordirectory.
nwuserlist(Userlist):ListstheuserscurrentlyloggedintoaNetWarefileserver.
pqlist(PrintQueueList):DisplaysthecontentsofaNetWareprintqueue.
slist(ServerList):DisplaysalistofknownNetWarefileservers.

NDSandLinux

ALinuxdistributionbyCalderafeaturesarangeofcommerciallysupportedenhancements
includingfullyfunctionalNovellNetWareclientsupport.Thebasedistributionisthe
well-respectedRedHatLinux.CalderahasaddeditsNetworkDesktopproductstoit.The
NetWaresupportprovidesafullyfeaturedNovellNetWareclientbuiltonatechnology
licensedfromNovell.Theclientprovidesfull-clientaccesstoNovell3.xand4.x
fileservers,andincludesfeaturessuchasNetWareDirectoryService(NDS)andRSA
encryption.IfyouworkwithinaNetWare4.xorNDSenvironment,thentheCaldera
NetWareClientistheonlysolutionavailable.Youcanobtainmuchmoreinformation
andorderingdetailsfromtheCalderaWebserveratwww.caldera.com/.

Usefuldocuments

TogetmoreinformationonIPXandNetWaresupport,readtheIPX-HOWTO.Thisdocument
presumesthatyouunderstandhowtobuildaLinuxkernelwiththeappropriatenetworking
optionsselected,andthatyouknowhowtousethebasicnetworkingtoolssuchas
ifconfigandroute.Ifyoudonot,readtheNET-3-HOWTO(NET-3-HOWTO.html).Someother
LinuxHOWTOdocumentsthatmightbeusefulare:TheEthernet-HOWTO(Ethernet-HOWTO.html),
whichdescribesthedetailsofconfiguringanEthernetdeviceforLinux;thePPP-HOWTO
(PPP-HOWTO.html),whichexplainstheavailableIPXsupportforversion2.2.0dandlater
oftheLinuxPPPimplementation.

Latestversionsofthesefilescanbeobtainedfromsunsite.unc.edu/pub/Linux/docs/HOWTO/IPX-HOWTO.
InyourLinuxbox,theHOW-TOsarelocatedinthe/usr/doc/HOWTOdirectoryinacompressed
format.Toviewthesefiles,typezlessIPX-HOWTO.gz.

DivyaMahajan

五.利用Raid1功能进行镜像备份。
把有重要数据的单独分区进行raid1镜像,用两个硬盘,对数据分区给以同样大小的柱面数和大小
附:在RedHat6.0里设置RAID(http://www.tt.tzptt.zj.cn/linux/useskill/raid.htm)
《Linux公报》……让Linux更富魅力!

目录:
资源
RAID介绍
设置RAID条带(RAIDStrip)
设置RAID镜象
使用一个空闲的设备设置RAID5
注解
你可以在这个地址http://www.tcu-inc.com/mark/articles/Raid.html找到本文的最新版本。
--------------------------------------------------------------------------------

资源
http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/
/usr/doc/raidtools-0.90
这些文章介绍了硬件细节,这部份内容在本文中不会涉及。
这是DPTHOWTO的地址,http://www.ram.org/computing/linux/dpt_raid.html

--------------------------------------------------------------------------------

RAID介绍
我建议你读一读jakob@ostenfeld.dk写的软件RAIDHOWTO。很明显,他是个丹麦人。丹麦是
一个住着许多聪明人的世界上最好的国家。他的这篇HOWTO写得非常好,也许我根本就没有
必要写这篇文章。我之所以写这篇文章是因为文档一般来说都写得不大容易懂,当然现在情况
已有很大的改观。本文中介绍的安装是在RedHat6.0上进行的,我认为在其他的Linux版本中
应该也能用。我什么时候会转去用Debian呢?我希望能尽快。
什么是RAID?简单的说,它可以让你在几个硬盘上做些有趣的事。它可以让你把几个硬盘合并
起来,把数据分散地存放在这几个硬盘中。它可以提高往硬盘读写数据的速度,也可以在硬盘
上备份数据。这样即使你有一个硬盘坏了,你还可以从其他的硬盘中恢复所有的数据。你可以
读读软件RAIDHOWTO中有关RAID级别的部份来更好的了解不同类型的软件RAID。

为了试验本文中的例子,你需要设置一些小的分区。我建议你设置一个1G的扩展分区,然后在
这个扩展分区上建一些100兆的逻辑分区。请千万要记住,你只能在一个无关紧要的硬盘上进行
试验。如果你毁了这个硬盘上的数据,那是你自己的错。即使我的文章中写得不对,你也必需
对自己的所作所为负责。


--------------------------------------------------------------------------------

RAID条带(stripRAID)
我只准备介绍如何设置RAID条带来存放数据。也就是说,我不会把操作系统的主要部份放在RAID
条带上。用RAID条带来存放整个系统会带来一些问题,所以我不准备这么做。
简单的说,在Linux系统上设置RAID条带需要四个步骤。条带把数据存放在两个或更多的硬盘
(实际上是分区)上,这些数据有一半是在一个硬盘上,另一半在另一个硬盘上。这样可以提高
硬盘读写的速度,因为数据是从两个硬盘上同时读出来的。再说一次,你可以在HOWTO读到更
详细的内容。

首先,我们要配置/dev/md0,然后我们要格式化这些分区,接下来要配置/etc/rc.d/rc.local
来激活RAID,最后要配置/etc/rc.d/rc.local来把这些设备安装到某个目录。

具体步骤

现在,我要使用一些小窍门。我认为大多数的低端用户并没有两个硬盘,所以我要使用同一个
硬盘上的两个分区而不是两个硬盘。建立一个有两个逻辑分区的扩展分区。这两个分区,
/dev/hda5和/dev/hda6,的大小必需一样。在同一个硬盘上的两个分区之间进行RAID条带是
没有任何意义的,即使是在同一个IDE控制器的不同硬盘上这么做也是没有意义的。请记住,
这只不过是个练习。

在/etc/raidtab中这么写:
raiddev/dev/md0

raid-level0

nr-raid-disks2

nr-spare-disks0

chunk-size4

persistent-superblock1

device/dev/hda5

raid-disk0

device/dev/hda6

raid-disk1

使用以下命令格式化分区
mkraid/dev/md0

如果你在用"mkraid"命令时出了些问题,它应该会给出如何解决问题的提示。然后执行如下命令:
mkfs-text2/dev/md0

接着,你可以在"/proc/mdstat"文件中查raid的状态。
cat/proc/mdstat

执行以下命令会在/etc/rc.d/rc.local中增加一行
echo"raidstart/dev/md0">>/etc/rc.d/rc.local

把这个命令执行一次。这可以为RAID设备建好目录并在/etc/rc.d/rc.local中增加一条命令。
mkdir/RAID

echo"mount/dev/md0/RAID">>/etc/rc.d/rc.local

如果你不想重启动计算机,你现在就可以激活RAID,
raidstart/dev/md0

mount/dev/md0/RAID

你可以用此命令来检查已经安装的目录。
df


--------------------------------------------------------------------------------

RAID镜象
和以上的例子一样,我要使用同一个硬盘上的两个分区,并且我也只对数据分区进行镜象。


首先,设置/dev/md0,然后格式化分区,接着配置/etc/rc.d/rc.local来激活raid,最后配置
/etc/rc.d/rc.local来把镜象设备安装到一个目录下。

如下设置/etc/raidtab
raiddev/dev/md0

raid-level1

nr-raid-disks2

nr-spare-disks0

chunk-size4

persistent-superblock1

device/dev/hda5

raid-disk0

device/dev/hda6

raid-disk1

用以下命令格式化分区
mkraid/dev/md0

如果你在用"mkraid"命令时出了些问题,它应该会给出如何解决问题的提示。然后执行如下命令:
mkfs-text2/dev/md0

接着,你可以在"/proc/mdstat"文件中查raid的状态。


cat/proc/mdstat

执行以下命令会在/etc/rc.d/rc.local中增加一行
echo"raidstart/dev/md0">>/etc/rc.d/rc.local

把这个命令执行一次。这可以为RAID设备建好目录并在/etc/rc.d/rc.local中增加一条命令。
mkdir/RAID

echo"mount/dev/md0/RAID">>/etc/rc.d/rc.local

如果你不想重启动计算机,你现在就可以激活RAID,
raidstart/dev/md0

mount/dev/md0/RAID

你可以用此命令来检查已经安装的目录。
df


--------------------------------------------------------------------------------

使用空闲的分区设置RAID5
使用一个空闲的设备来试验RAID5是一件很酷的事。我们还是只用一个硬盘。一般来说,我都会
建立一个100M的逻辑分区来进行试验。如果你有一个1G的扩展的分区,那你就可以有10个逻辑
分区来进行各种试验。
具体的步骤和以上介绍的镜象以及条带一样,把配置文件按以下修改。

raiddev/dev/md0

raid-level5

nr-raid-disks7

nr-spare-disks1

persistent-superblock1

parity-algorithmleft-symmetric

chunk-size32

device/dev/hda5

raid-disk0

device/dev/hda6

raid-disk1

device/dev/hda7

raid-disk2

device/dev/hda8

raid-disk3

device/dev/hda9

raid-disk4

device/dev/hda10

raid-disk5

device/dev/hda11

raid-disk6

###Also,letushaveasparedevice

device/dev/hda12

spare-disk0


--------------------------------------------------------------------------------

注解
请使用/etc/rc.d/rc.local来安装raid设备,而不要用/etc/fstab。如果你想用/etc/fstab,
你尽可以试一试。这多半没有用,但有些人就是喜欢自己试试看(就象我一样)。
这些文档以前写得挺难懂得,但这些HOWTO已经更新过了,这些工具也变得更好用了。现在,在
这些例子的帮助下,任何一个会用Linux的人都可以设置一个raid设备。希望这可以帮助降低RAID
服务器的价钱。

如果你想更好的使用软件RAID,请用U2WSCSI控制器,象Adaptec控制器或其他的好品牌,如DPT,Mylex等。
对于只需要镜象而不考虑速度的比较便宜的raid,也可以使用IDE控制器。如果你想更进一步使用硬件RAID,
有几个公司支持Linux的硬件RAID。


--------------------------------------------------------------------------------

Mark在TheComputerUnderground公司当一个接待员(短裤,T恤),在800linux.com当专业人员
(西装领带)。在空余时间做一些志愿工作,比如写一些象本文一样的文章来帮助那些需要帮助的人。
本文使用emacs和ispell编辑。


版权所有?1999NJLUG
出版于第45期《Linux公报》1999年9月中文版第十一期

--------------------------------------------------------------------------------
其它RAID资料:
StripeandMirroringRAIDunderRedHat6.0(http://www.tcu-inc.com/mark/articles/Raid.html)

版权声明:本文由驱动中国整理发布,转载需注明出处与原文链接。如有疑问请联系 editor@qudong.com
本文价值 成为第一个评分的人
登录后为本文打分
网友评论0 条评论
正在回复 的评论取消
评论加载中…
🔐

登录后参与互动

评论、点赞均可赚积分
连续签到、邀请好友也有奖励 🎁

电脑端: 微信扫码登录 微信内: 一键登录

微信扫一扫

打开微信「扫一扫」,分享本文到朋友圈或好友