Register
It is currently Mon Nov 24, 2014 6:06 am

interpreting fstab


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sun Jun 14, 2009 5:43 pm   

Joined: Sun Jun 14, 2009 5:29 pm
Posts: 1
hi folks,

after years of gentoo experience i decided to get in touch with bash scripting. for the well known purpose of backing up my system.

first step would be to name the folders/partitions i want to backup. for the sake of beaty i want to try something like this. i hope you excuse my ignorance to bash, therefore i'll try with pseudo code. i hope i'll improve soon...

Code:
#!/bin/bash

# ------- Source Locations ---------
SOURCE_PARTITIONS="/ /home /usr /var"

# --------- System Setup -----------
BACKUP_DESTINATION=/mnt/backup
FSTAB=/etc/fstab

#here should be some magick
for SOURCE in $SOURCE_PARTITIONS
do
   #get corresponding path from fstab <---------------------- need help here
done


again sorry for my noobness!!!


cheers!

alex


Top
 Profile  
 PostPosted: Mon Jun 15, 2009 7:59 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 567
Code:
#!/bin/bash
srcPartitions=(/ /home /usr /var) # this is an array
bakDest="/mnt/backup"
fstab="/etc/fstab"

for src in ${srcPartitions[@]}
do
   sed -n '\@'"$src"' @p' $fstab
# there's a space her^e
done
you might pipe the sed expression to cut, or find a regular expression in sed to fit your needs.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP