proggybilly
Programmer
I have a script that creates a tbz file as a "backup" of some system directories on a linux server and then rsync's that to another server, the code looks like this:
I want to pull config information from another file, the file info looks like this:
172.16.254.3
255.255.255.0
172.16.254.1
172.16.254.105
197
198
196
M
172.16.254.20
phonesync
12345
phonesync
on
I need to first check if the last line equals on, then I need to pull data from the file, the info I need is from below the M to the end so that my code will now look like this:
I bolded the changes that would come from the config file.
I need to know how to pull that data into an array and get the total number of elements so i can do something similar to
then I need the specific items starting at the last element and working backwards to populate into the areas you see in bold.
Please, can anyone help. I am a severe newb at bash scripting.
Code:
#!/bin/sh
/usr/bin/find /backup -type f -ctime +1 ! -exec rm {} \;
/usr/bin/find /var/lib/asterisk/backups -type f -ctime +7 ! -exec rm {} \;
cd /
filename="system-`date +'%Y%m%d%H%M'`.tbz2"
filenm1="/backup/$filename"
START=`date +%s`
START1=`date +"%Y-%m-%d %H:%M:%S"`
tar -jcf $filenm1 -X /etc/backup.exclude ./usr/lbin ./etc ./var
FILESBACK=`grep -c "/" $filenm1`
FILESIZE=`du -shm $filenm1`
RSYNC_PASSWORD=Asbak12
export RSYNC_PASSWORD
cd /backup
/usr/bin/rsync -r -p --force $filename astback@dis::astback
I want to pull config information from another file, the file info looks like this:
172.16.254.3
255.255.255.0
172.16.254.1
172.16.254.105
197
198
196
M
172.16.254.20
phonesync
12345
phonesync
on
I need to first check if the last line equals on, then I need to pull data from the file, the info I need is from below the M to the end so that my code will now look like this:
Code:
#!/bin/sh
/usr/bin/find /backup -type f -ctime +1 ! -exec rm {} \;
/usr/bin/find /var/lib/asterisk/backups -type f -ctime +7 ! -exec rm {} \;
cd /
filename="system-`date +'%Y%m%d%H%M'`.tbz2"
filenm1="/backup/$filename"
START=`date +%s`
START1=`date +"%Y-%m-%d %H:%M:%S"`
tar -jcf $filenm1 -X /etc/backup.exclude ./usr/lbin ./etc ./var
FILESBACK=`grep -c "/" $filenm1`
FILESIZE=`du -shm $filenm1`
RSYNC_PASSWORD=[b]12345[/b]
export RSYNC_PASSWORD
cd /backup
/usr/bin/rsync -r -p --force $filename [b]phonesync[/b]@[b]172.16.254.20[/b]::[b]phonesync[/b]
I bolded the changes that would come from the config file.
I need to know how to pull that data into an array and get the total number of elements so i can do something similar to
Code:
if !$ARRAY[$i] == on then exit else continue
Please, can anyone help. I am a severe newb at bash scripting.