Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

HowToBackUpanUbuntu14.04ServerwithBacula
Apr17,2015

BackupsUbuntu

TutorialSeries
Thistutorialispart2of4intheseries:HowToUse
BaculaonUbuntu14.04

Introduction
ThistutorialwillshowyouhowtosetupBaculatocreatebackupsofaremoteUbuntu
14.04host,overanetworkconnection.Thisinvolvesinstallingandconfiguringthe
BaculaClientsoftwareonaremotehost,andmakingsomeadditionstothe
configurationofanexistingBaculaServer(coveredintheprerequisites).
IfyouaretryingtocreatebackupsofCentOS7hosts,followthislinkinstead:HowTo
BackUpaCentOS7ServerwithBacula.

Prerequisites
ThistutorialassumesthatyouhaveaserverrunningtheBaculaServercomponents,
asdescribedinthislink:HowToInstallBaculaServeronUbuntu14.04.
Wearealsoassumingthatyouareusingprivatenetworkinterfacesforbackupserver
clientcommunications.WewillrefertotheprivateFQDNoftheservers(FQDNsthat
pointtotheprivateIPaddresses).IfyouareusingIPaddresses,simplysubstitutethe
connectioninformationwhereappropriate.
Fortherestofthistutorial,wewillrefertotheBaculaServeras"BaculaServer",
"BaculaServer",or"BackupServer".Wewillrefertotheremotehost,thatisbeing
backedup,as"ClientHost","ClientHost",or"Client".
Let'sgetstartedbymakingsomequickchangestotheBaculaServerconfiguration.

OrganizeBaculaDirectorConfiguration(Server)
https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

1/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

OnyourBaculaServer,performthissectiononce.
WhensettingupyourBaculaServer,youmayhavenoticedthattheconfigurationfiles
areexcessivelylong.We'lltryandorganizetheBaculaDirectorconfigurationabit,soit
usesseparatefilestoaddnewconfigurationsuchasjobs,filesets,andpools.
Let'screateadirectorytohelporganizetheBaculaconfigurationfiles:

sudomkdir/etc/bacula/conf.d

ThenopentheBaculaDirectorconfigurationfile:

sudovi/etc/bacula/baculadir.conf

Attheendofthefileadd,thisline:
baculadir.confAddtoendoffile
@|"find/etc/bacula/conf.dname'*.conf'typefexececho@{}\;"

Saveandexit.ThislinemakestheDirectorlookinthe /etc/bacula/conf.d directory


foradditionalconfigurationfilestoappend.Thatis,any .conf fileaddedintherewill
beloadedaspartoftheconfiguration.

AddRemoteFilePool
WewanttoaddanadditionalPooltoourBaculaDirectorconfiguration,whichwe'lluse
toconfigureourremotebackupjobs.
Openthe conf.d/pools.conf file:

sudovi/etc/bacula/conf.d/pools.conf

AddthefollowingPoolresource:
conf.d/pools.confAddPoolresource
https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

2/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

Pool{
Name=RemoteFile
PoolType=Backup
LabelFormat=Remote
Recycle=yes#BaculacanautomaticallyrecycleVolumes
AutoPrune=yes#Pruneexpiredvolumes
VolumeRetention=365days#oneyear
MaximumVolumeBytes=50G#LimitVolumesizetosomethingreasonable
MaximumVolumes=100#LimitnumberofVolumesinPool
}

Saveandexit.Thisdefinesa"RemoteFile"pool,whichwewillusebythebackupjob
thatwe'llcreatelater.Feelfreetochangeanyoftheparameterstomeetyourown
needs.
Wedon'tneedtorestartBaculaDirectorjustyet,butlet'sverifythatitsconfiguration
doesn'thaveanyerrorsinit:

sudobaculadirtc/etc/bacula/baculadir.conf

Iftherearenoerrors,you'rereadytocontinueontotheBaculaClientsetup.

InstallandConfigureBaculaClient
PerformthissectiononanyClientHostthatyouareaddingtoyourBaculasetup.
First,updateaptget:

sudoaptgetupdate

Theninstallthe baculaclient package:

sudoaptgetinstallbaculaclient

ThisinstallstheBaculaFileDaemon(FD),whichisoftenreferredtoasthe"Bacula
client".
https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

3/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

ConfigureClient
BeforeconfiguringtheclientFileDaemon,youwillwanttolookupthefollowing
information,whichwillbeusedthroughouttheremainderofthistutorial:
Clienthostname::Ourexamplewilluse"ClientHost"
ClientPrivateFQDN:We'llrefertothisas"client_private_FQDN",whichmaylook
like clienthost.private.example.com
BaculaServerhostname:Ourexamplewilluse"BackupServer"
Youractualsetupwillvaryfromtheexample,sobesuretomakesubstitutionswhere
appropriate.
OpentheFileDaemonconfiguration:

sudovi/etc/bacula/baculafd.conf

Weneedtochangeafewitemsandsavesomeinformationthatwewillneedforour
serverconfiguration.
BeginbyfindingtheDirectorresourcethatisnamedafteryourclienthostname(e.g.
"ClientHostdir").AstheBaculaDirectorthatwewanttocontrolthisClientislocatedon
theBaculaServer,changethe"Name"parametertothehostnameofyourbackup
serverfollowedby"dir".Followingourexample,with"BackupServer"astheBacula
Server'shostname,itshouldlooksomethinglikethisafterbeingupdated:
baculafd.confUpdateDirectorName
Director{
Name=BackupServerdir
Password="IrIK4BHRA2o5JUvw2C_YNmBX_70oqfaUi"
}

Youalsoneedtocopythe Password ,whichistheautomaticallygeneratedpassword


usedforconnectionstoFileDaemon,andsaveitforfuturereference.Thiswillbeused
intheBackupServer'sDirectorconfiguration,whichwewillsetinanupcomingstep,to
connecttoyourClient'sFileDaemon.

https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

4/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

Next,weneedtoadjustoneparameterintheFileDaemonresource.Wewillchange
the FDAddress parametertomatchtheprivateFQDNofourclientmachine.
The Name parametershouldalreadybepopulatedcorrectlywiththeclientfiledaemon
name.Theresourceshouldlookssomethinglikethis(substitutetheactualFQDNorIP
address):
baculafd.confUpdateFDAddress
FileDaemon{#thisisme
Name=ClientHostfd
FDport=9102#wherewelistenforthedirector
WorkingDirectory=/var/lib/bacula
PidDirectory=/var/run/bacula
MaximumConcurrentJobs=20
FDAddress=client_private_FQDN
}

WealsoneedtoconfigurethisdaemontopassitslogmessagestotheBackupServer.
FindtheMessagesresourceandchangethe director parametertomatchyour
backupserver'shostnamewitha"dir"suffix.Itshouldlooksomethinglikethis:
baculafd.confUpdatedirector
Messages{
Name=Standard
director=BackupServerdir=all,!skipped,!restored
}

Savethefileandexit.YourFileDaemon(BaculaClient)isnowconfiguredtolistenfor
connectionsovertheprivatenetwork.
Checkthatyourconfigurationfilehasthecorrectsyntaxwiththefollowingcommand:

sudobaculafdtc/etc/bacula/baculafd.conf

Ifthecommandreturnsnooutput,theconfigurationfilehasvalidsyntax.Restartthe
filedaemontousethenewsettings:

https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

5/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

sudoservicebaculafdrestart

Let'ssetupadirectorythattheBaculaServercanrestorefilesto.Createthefile
structureandlockdownthepermissionsandownershipforsecuritywiththefollowing
commands:

sudomkdirp/bacula/restore
sudochownRbacula:bacula/bacula
sudochmodR700/bacula

Theclientmachineisnowconfiguredcorrectly.Next,wewillconfiguretheBackup
ServertobeabletoconnecttotheBaculaClient.

AddFileSets(Server)
ABaculaFileSetdefinesasetoffilesordirectoriestoincludeorexcludefilesfroma
backupselection,andareusedbybackupjobsontheBaculaServer.
Ifyoufollowedtheprerequisitetutorial,whichsetsuptheBaculaServercomponents,
youalreadyhaveaFileSetcalled"FullSet".IfyouwanttorunBackupjobsthatinclude
almosteveryfileonyourBackupClients,youcanusethatFileSetinyourjobs.You
mayfind,however,thatyouoftendon'twantorneedtohavebackupsofeverythingon
aserver,andthatasubsetofdatawillsuffice.
BeingmoreselectiveinwhichfilesareincludedinaFileSetwilldecreasetheamount
ofdiskspaceandtime,requiredbyyourBackupServer,torunabackupjob.Itcan
alsomakerestorationsimpler,asyouwon'tneedtosiftthroughthe"FullSet"tofind
whichfilesyouwanttorestore.
WewillshowyouhowtocreatenewFileSetresources,sothatyoucanbemore
selectiveinwhatyoubackup.
OnyourBaculaServer,openafilecalled filesets.conf ,intheBaculaDirector
configurationdirectorywecreatedearlier:

sudovi/etc/bacula/conf.d/filesets.conf
https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

6/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

CreateaFileSetresourceforeachparticularsetoffilesthatyouwanttouseinyour
backupjobs.Inthisexample,we'llcreateaFileSetthatonlyincludesthehomeandetc
directories:
filesets.confAddHomeandEtcFileSet
FileSet{
Name="HomeandEtc"
Include{
Options{
signature=MD5
compression=GZIP
}
File=/home
File=/etc
}
Exclude{
File=/home/bacula/not_important
}
}

Therearealotofthingsgoingoninthisfile,buthereareafewdetailstokeepinmind:
TheFileSetNamemustbeunique
Includeanyfilesorpartitionsthatyouwanttohavebackupsof
Excludeanyfilesthatyoudon'twanttobackup,butwereselectedasaresultof
existingwithinanincludedfile
YoucancreatemultipleFileSetsifyouwish.Saveandexit,whenyouarefinished.
Nowwe'rereadytocreatebackupjobthatwilluseournewFileSet.

AddClientandBackupJobtoBaculaServer
Nowwe'rereadytoaddourClienttotheBaculaServer.Todothis,wemustconfigure
theBaculaDirectorwithnewClientandJobresources.
Openthe conf.d/clients.conf file:

https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

7/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

sudovi/etc/bacula/conf.d/clients.conf

AddClientResource
AClientresourceconfigurestheDirectorwiththeinformationitneedstoconnecttothe
ClientHost.Thisincludesthename,address,andpasswordoftheClient'sFile
Daemon.
PastethisClientresourcedefinitionintothefile.BesuretosubstituteinyourClient
hostname,privateFQDN,andpassword(fromtheClient's baculafd.conf ),where
highlighted:
conf.d/clients.confAddClientresource
Client{
Name=ClientHostfd
Address=client_private_FQDN
FDPort=9102
Catalog=MyCatalog

Password="IrIK4BHRA2o5JUvw2C_YNmBX_70oqfaUi"#passwordforRemoteFileDaemo
FileRetention=30days#30days
JobRetention=6months#sixmonths
AutoPrune=yes#PruneexpiredJobs/Files
}

YouonlyneedtodothisonceforeachClient.

Createabackupjob:
ABackupjob,whichmusthaveauniquename,definesthedetailsofwhichClientand
whichdatashouldbebackedup.
Next,pastethisbackupjobintothefile,substitutingtheClienthostnameforthe
highlightedtext:
conf.d/clients.confAddBackupjobresource
Job{
Name="BackupClientHost"
https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

8/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

JobDefs="DefaultJob"
Client=ClientHostfd
Pool=RemoteFile
FileSet="HomeandEtc"
}

Thiscreatesabackupjobcalled"BackupClientHost",whichwillbackupthehomeand
etcdirectoriesoftheClientHost,asdefinedinthe"HomeandEtc"FileSet.Itwilluse
thesettingsspecifiedinthe"DefaultJob"JobDefsand"RemoteFile"Poolresources,
whicharebothdefinedinthemain baculadir.conf file.Bydefault,jobsthat
specify JobDefs="DefaultJob" willrunweekly.
Saveandexitwhenyouaredone.

VerifyDirectorConfiguration
Let'sverifythattherearenosyntaxerrorsinyourDirectorconfigurationfile:

sudobaculadirtc/etc/bacula/baculadir.conf

Ifyouarereturnedtotheshellprompt,therearenosyntaxerrorsinyourBacula
Director'sconfigurationfiles.

RestartBaculaDirector
Toputtheconfigurationchangesthatyoumadeintoeffect,restartBaculaDirector:

sudoservicebaculadirectorrestart

NowyourClient,orremotehost,isconfiguredtobebackedupbyyourBaculaServer.

TestClientConnection
WeshouldverifythattheBaculaDirectorcanconnecttotheBaculaClient.
OnyourBaculaServer,entertheBaculaConsole:

sudobconsole
https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

9/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

statusclient

SelectClientresource:ClientHostfd
ThedefinedClientresourcesare:
1:BackupServerfd
2:ClientHostfd
SelectClient(Filedaemon)resource(12):2

TheClient'sFileDaemonstatusshouldreturnimmediately.Ifitdoesn't,andthereisa
connectionerror,thereissomethingwrongwiththeconfigurationoftheBaculaServer
oroftheClient'sFileDaemon.

TestBackupJob
Let'srunthebackupjobtomakesureitworks.
OntheBaculaServer,whilestillintheConsole,usethiscommand:

run

YouwillbepromptedtoselectwhichJobtorun.Selecttheonewecreatedearlier,e.g.
"4.BackupClientHost":

SelectJobresource:BackupClientHost
ThedefinedJobresourcesare:
1:BackupLocalFiles
2:BackupCatalog
3:RestoreLocalFiles
4:BackupClientHost
SelectJobresource(14):4

Attheconfirmationprompt,enter"yes":

Confirmationprompt:
OKtorun?(yes/mod/no):yes
https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

10/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

CheckMessagesandStatus
Afterrunningajob,Baculawilltellyouthatyouhavemessages.Themessagesare
outputgeneratedbyrunningjobs.
Checkthemessagesbytyping:

messages

Themessagesshouldsay"NopriorFullbackupJobrecordfound",andthatthe
backupjobstarted.Ifthereareanyerrors,somethingiswrong,andtheyshouldgive
youahintastowhythejobdidnotrun.
AnotherwaytoseethestatusofthejobistocheckthestatusoftheDirector.Todo
this,enterthiscommandatthebconsoleprompt:

statusdirector

Ifeverythingisworkingproperly,youshouldseethatyourjobisrunningorterminated
withan"OK"status.

PerformRestore
ThefirsttimeyousetupanewBaculaClient,youshouldtestthattherestoreworks
properly.
Ifyouwanttoperformarestore,usethe restore commandattheBaculaConsole:

restoreall

Aselectionmenuwillappearwithmanydifferentoptions,whichareusedtoidentify
whichbackupsettorestorefrom.Sinceweonlyhaveasinglebackup,let's"Selectthe
mostrecentbackup"selectoption5:

Selectitem(113):
https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

11/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

ThenyoumustspecifywhichClienttorestore.Wewanttorestoretheremotehostthat
wejustsetup,e.g."ClientHostfd":

SelecttheClient:ClientHostfd
DefinedClients:
1:BackupServerfd
2:ClientHostfd
SelecttheClient(12):2

Thiswilldropyouintoavirtualfiletreewiththeentiredirectorystructurethatyou
backedup.Thisshelllikeinterfaceallowsforsimplecommandstomarkandunmark
filestoberestored.
Becausewespecifiedthatwewantedto"restoreall",everybackedupfileisalready
markedforrestoration.Markedfilesaredenotedbyaleading * character.
Ifyouwouldliketofinetuneyourselection,youcannavigateandlistfileswiththe"ls"
and"cd"commands,markfilesforrestorationwith"mark",andunmarkfileswith
"unmark".Afulllistofcommandsisavailablebytyping"help"intotheconsole.
Whenyouarefinishedmakingyourrestoreselection,proceedbytyping:

done

Confirmthatyouwouldliketoruntherestorejob:

OKtorun?(yes/mod/no):
yes

CheckMessagesandStatus
Aswithbackupjobs,youshouldcheckthemessagesandDirectorstatusafterrunning
arestorejob.

https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

12/13

03/05/2016

HowToBackUpanUbuntu14.04ServerwithBacula|DigitalOcean

Checkthemessagesbytyping:

messages

Thereshouldbeamessagethatsaystherestorejobhasstartedorwasterminated
withan"RestoreOK"status.Ifthereareanyerrors,somethingiswrong,andthey
shouldgiveyouahintastowhythejobdidnotrun.
Again,checkingtheDirectorstatusisagreatwaytoseethestateofarestorejob:

statusdirector

Whenyouarefinishedwiththerestore,type exit toleavetheBaculaConsole:

exit

Ifeverythingworkedproperly,yourrestoredfileswillbeonyourClienthost,in
the /bacula/restore directory.Ifyouweresimplytestingtherestoreprocess,you
shoulddeletethecontentsofthatdirectory.

Conclusion
YounowhaveaBaculaServerthatisbackingupfilesfromaremoteBaculaClient.Be
suretoreviewandreviseyourconfigurationuntilyouarecertainthatyouarebacking
upthecorrectFileSets,onaschedulethatmeetsyourneeds.Ifyouaretryingto
createbackupsofCentOS7hosts,followthislink:HowToBackUpaCentOS7
ServerwithBacula.
Thenextthingyoushoulddoisrepeattherelevantsectionsofthistutorialforany
additionalUbuntu14.04serversthatyouwanttobackup.

https://www.digitalocean.com/community/tutorials/howtobackupanubuntu1404serverwithbacula

13/13

You might also like