[Box Backup] sillyrestore.bash

Mikael Syska boxbackup@fluffy.co.uk
Tue, 01 Mar 2005 08:11:38 +0100


Hey,

There are a "restore" command in the bbackupquery to restore a complete 
directory....

regards
Mikael Syska

Justin H Haynes wrote:

> I wasn't paying attention and started bbackupd before trying to 
> restore all my files to my laptop. Oops.  Thankfully the files were 
> still there and marked as deleted.  It was just a bit more tedious to 
> get them back because there isn't a fast way to do that kind of a 
> restore yet.
> If anyone else has this problem, until the client features are there, 
> you might find this script useful.  I needed to write it so I didn't 
> have to individually restore 17000 files with bbackupquery by hand.
>
> If I have already posted this, I'm sorry.  I thought I had posted it a 
> couple of weeks ago, but when I checked the archives, I didn't find it:
>
> bash-3.00$ cat sillyrestore.bash
> #!/bin/bash
> # This is sillyrestore.bash
> #
> # This is one tool you can use if you lamely intended
> # to restore all your files, but instead started bbackupd
> # and marked them all deleted. #
> # This script is sloppy and inefficient and connects with bbackupquery
> # for each and every file.  It also blindly tries to create directories
> # without even checking.  It is provided as a skeleton. #
> # sillyrestore.bash expects get.txt produced like this (which you
> # probably need to do as root or as the user who runs the client):
> #
> # bbackupquery "ls -rdo" > get.txt
> #
> # sillyrestore.bash creates absolute paths.  So if 
> home/justin/whatever.txt
> # exists on the store, then it will be restored as 
> /home/justin/whatever.txt
> # change this if you want.
>
> echo populate ids
> count=0
> for i in `cat get.txt | awk '{print $1}'`
> do
> ids[$count]=$i
> count=$[$count + 1]
> done
>
> echo populate files
> count=0
> for i in `cat get.txt | awk '{print $3}'`
> do
> files[$count]=$i
> count=$[$count + 1]
> done
> maxcount=`expr $count - 1`
>
>
>
> count=0
> while test $count -le $maxcount
> do
> dirname=`dirname ${files[$count]}`
> basename=`basename ${files[$count]}`
> mkdir -p /$dirname
> chown -R justin:justin /$dirname
> echo bbackupquery \"cd -do /$dirname\" \"lcd /$dirname\" \"get -i 
> ${ids[$count]} $basename\"
> bbackupquery "cd -do /$dirname" "lcd /$dirname" "get -i ${ids[$count]} 
> $basename" "exit"
>
> count=$[$count + 1]
> done
> bash-3.00$
> _______________________________________________
> boxbackup mailing list
> boxbackup@fluffy.co.uk
> http://lists.warhead.org.uk/mailman/listinfo/boxbackup