You are not logged in.

#1 2010-01-26 07:16:29

PiklesOnFire
Member
From: USA
Registered: 2009-04-10
Posts: 21
Website

Didn't know where to put this - Bash script help

I have a lot of backups I have made with dar.
There are 4 subdirectories in a main /Backups directory.
the sub-directories are week1, week2, week3, and week4.

What I have is a script to take the backups.
Now what I would like to impliment is a script to RESTORE them.

I have most of it built, but I need some help with a part that I can't seem to find on google anywhere.
I have my backups named in a YYYY-MM-DD_hh:mm:ss format (all end in .1.dar).
I'm trying to find a way to extract all the backups in one of the week folders UP TO the one I have entered on command line.
IE: I'm trying to restore my system to 2010-01-15, so I would like the last file that contains that in its name, to be restored last, and all backups before it first.
can ANYONE help me?

I've been working at this for days, and this part is just hanging me up...
any help would be appreciated.


Ok, I figured out how to glob the files in an array, how would i find the number of the array element that matches $STRING? anyone? anyone?

Found it nvm /palmface

Last edited by PiklesOnFire (2010-01-26 07:38:42)


System Error: Signature not found.
(ohnoze!!!)

Offline

#2 2010-01-26 07:53:21

the_isz
Member
Registered: 2009-04-14
Posts: 280

Re: Didn't know where to put this - Bash script help

I don't think I've completely understood your problem, but this might help you:

if [[ "2010-01-15_06:35:23.1.dar" =~ ^([[:digit:]]{4})-([[:digit:]]{2})-([[:digit:]]{2})_([[:digit:]]{2}):([[:digit:]]{2}):([[:digit:]]{2})\.1\.dar$ ]]; then
  for n in {1..6}; do
    echo ${BASH_REMATCH[$n]};
  done
fi

Offline

#3 2010-01-26 07:58:57

PiklesOnFire
Member
From: USA
Registered: 2009-04-10
Posts: 21
Website

Re: Didn't know where to put this - Bash script help

er... not rly =/

i'm trying to find all the files in week1/system or week1/home, but i only want the ones up to a certain date.
an example not using dates would be... i have files 1.tar-100000000000.tar
say i search for 932, what i'm trying to do is get an array of all the files that are 1-932.

I hope that clarifies things a bit. I'm still googling trying to find a way to do this, and sitting in the bash irc atm. lol


System Error: Signature not found.
(ohnoze!!!)

Offline

#4 2010-01-26 08:03:39

the_isz
Member
Registered: 2009-04-14
Posts: 280

Re: Didn't know where to put this - Bash script help

Have you tried running the script I gave you? It extracts the year, month, day,
etc from the file name (you'd just replace the constant file string with a
variable). With this information, you should be able to write a script that
matches your search.

Last edited by the_isz (2010-01-26 08:03:51)

Offline

#5 2010-01-26 08:20:34

PiklesOnFire
Member
From: USA
Registered: 2009-04-10
Posts: 21
Website

Re: Didn't know where to put this - Bash script help

the_isz wrote:

Have you tried running the script I gave you? It extracts the year, month, day,
etc from the file name (you'd just replace the constant file string with a
variable). With this information, you should be able to write a script that
matches your search.

lol i ran it, i just didn't look at it closely, you're right, it does exactly what i needed.
thank you very much :]


System Error: Signature not found.
(ohnoze!!!)

Offline

Board footer

Powered by FluxBB