SearchFAQMemberlist Log in
Reply to topic Page 1 of 1
locate and list script
Author Message
Post locate and list script 
I have been using the following small script to help
locate backed up files and list (ls) related info.
Here it is if anyone find it useful:

====Begin====
#!/bin/bash

echo ""
echo "Enter file to search for:"
read filename
locate -i $filename > /tmp/locate_list
echo ""

cat /tmp/locate_list | while read line; do ls -lih
"${line}"; done
echo ""

#
# Use "${line}" instead of just ${line} because locate
# returns a list of files and paths included spaces.
# For ls quotes or or an escape (\) is needed to treat

# a space as just that.
#

rm /tmp/locate_list

echo "Steps to restore a file and ownership:"
echo "1- scp -p <backup1/path/file>
root < at > filesrv1:<filesrv1/path/file>"
echo "2- ssh root < at > filesrv1 chown <00000:00000>
<filesrv1/path/file>"
echo ""

====Begin ====

I welcome any suggested improments to the script.
And can anyone comment on the following:

1 - How do turn line wrapping off on my terminals
(Konsole or gnome-terminal)? My file paths are very
long and resulting line wrapping makes the output
difficult to read.

2 - What is the easiest way from a terminal to copy a
file back to its source with the same mode and
ownership. Is there a better way than my 2 step method
above?

Thanks for any comments.
Bruce




____________________________________________________________________________________
Have a burning question?
Go to www.Answers.yahoo.com and get answers from real people who know.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
rsnapshot-discuss mailing list
rsnapshot-discuss < at > lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rsnapshot-discuss

Post locate and list script 
locate -i $filename > /tmp/locate_list

Hmm, on my system, locate doesn't index my /backups store since its not
universally accessible. You might want to include some notes for people
in this situation (still working it out myself).

2 - What is the easiest way from a terminal to copy a
file back to its source with the same mode and
ownership. Is there a better way than my 2 step method
above?

Perhaps 'rsync -a --numeric-ids backup/.../file origin:/.../file'?

Regards,
--
Dave Steinberg
http://www.geekisp.com/
http://www.steinbergcomputing.com/

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
rsnapshot-discuss mailing list
rsnapshot-discuss < at > lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rsnapshot-discuss

Post locate and list script 
On Fri, Jan 26, 2007 at 10:21:49AM -0500, Dave Steinberg wrote:

locate -i $filename > /tmp/locate_list
Hmm, on my system, locate doesn't index my /backups store since its not
universally accessible. You might want to include some notes for people
in this situation (still working it out myself).

locate doesn't index at all, it merely uses the indexes built by another
command. On Linux that command is normally updatedb. On OS X it's
/usr/libexec/locate.updatedb.

How to configure it on OS X is ... not obvious, but it *seems* to index
everything anyway and locate then sometimes returns files that the
current user can't access in directories he can't open. NAUGHTY OS X!

On Linux - at least on Debian anyway - updatedb is commonly run from a
script somewhere in /etc/cron.* and can be configured to run the indexer
as a particular user either by setting the LOCALUSER environment
variable in that script, or by setting it in /etc/updatedb.conf, or by
using the --localuser command line option. You can also configure which
file it stores the index in, so could control which users see which
indices by using a mixture of those two options. The database used by
the locate command can be set with an environment variable - which you
could set in users' startup scripts - so you should be able to preserve
security while still making it easy to use.

--
David Cantrell | A machine for turning tea into grumpiness

What profiteth a man, if he win a flame war, yet lose his cool?

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
rsnapshot-discuss mailing list
rsnapshot-discuss < at > lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rsnapshot-discuss

Display posts from previous:
Reply to topic Page 1 of 1
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 vote in polls in this forum
  


Magic SEO URL for phpBB