Skip to main content

Thread: Bash Loop - Server Backup Script


just giving community:

in process of coverting number of our file servers windows platform linux ubuntu samba platform. primary target being our file servers. along conversion process conversion of our backup scripts windows command line ubuntu bash.

noobs stumble around trying figure out how in ubuntu used in windows, hope gives example build on. following code used on our disaster recovery server, offsite backup server our onsite backup server. in particular process, data overlaid after each backup.

code:
#! /bin/bash  #  ### olfs - off line file server - bash  #  ### local file variables  #  inifl - ini space delimited file location  #  pwdpth - password file location  #     inifl=/mnt/rsyncme/data.ini     pwdpth=/mnt/domsvs/.pword  #  ### loop olfs08.ini file  #  olfs - olfs file server  #  evol - external volume number  #  sv - server name (folder)  #  sd2tb - target backup drives  #  while read olfs evol sv sd2tb      srcpth=//$olfs/$evol/$sv    mntpth=//mnt/domsvs/$olfs/$evol/$sv    trgpth=/mnt/exthds/$sd2tb/$sv  #    mkdir -p $mntpth    mkdir -p $trgpth  #    mount -t cifs $srcpth $mntpth -o credentials=$pwdpth    rsync -arvz --progress $mntpth/* $trgpth    umount $mntpth    done < $inifl  #  ### end
because learning how work reading files makes working scripting fun thought go while loop bit more detail - can't noob forever.


primer, keep in mind "data.ini" file standard text file has 4 data sets, each separated space. example contents of are:
code:
olfs08 evol1 dalfps sdc2tb  olfs08 evol2 denfps sdc2tb  olfs08 evol3 shrfps sdc2tb
looking @ while loop...
code:
while read olfs evol sv sd2tb      srcpth=//$olfs/$evol/$sv    mntpth=//mnt/tnpinc/$olfs/$evol/$sv    trgpth=/mnt/exthds/$sd2tb/$sv
the while loop reads first line of "data.ini" file , assigns each of line data elements string variable. therefore, first data set be

olfs = olfs08 - server has data
evol = evol1 - volume residing on server
sv = dalfps - folder residing within volume (named after server)
sd2tb = sdc2tb - volume name in data backed to

given 4 parts of data can create our
srcpth - source path - data resides
mntpth - mount path - server mount obtain data
trgpth - target path - data backed to


in event folders need created...
code:
  mkdir -p $mntpth    mkdir -p $trgpth
then mount, backup using rsync, , umount when complete...
code:
  mount -t cifs $srcpth $mntpth -o credentials=$pwdpth     rsync -arvz --progress $mntpth/* $trgpth    umount $mntpth
this handy piece of code completes while statement, tells while statement external file is
code:
done < $inifl

future bash script need create backup folders based on yyyymmdd hold incremental data.

hope helps out there.



Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] Bash Loop - Server Backup Script


Ubuntu

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account