need urgent help with mass file restore script...how??

max01

Registered
Oct 1, 2006
1
0
151
hello :)

i need to urgently restore a single file that is contained in most of my accounts that got wiped by a script in the server. but it is still contained in the backups, but it will take me ages to restore each and every one of them with cp -a /backup/daily/username/homedir/file to /home/username/file ..is there any mass way to do this? like a script that would do it for each account username?
 

beehave

Well-Known Member
Jun 26, 2005
104
0
166
max01 said:
hello :)

i need to urgently restore a single file that is contained in most of my accounts that got wiped by a script in the server. but it is still contained in the backups, but it will take me ages to restore each and every one of them with cp -a /backup/daily/username/homedir/file to /home/username/file ..is there any mass way to do this? like a script that would do it for each account username?
That sounds pretty easy to do. I need the exact file name and paths(not for each user).
 

beehave

Well-Known Member
Jun 26, 2005
104
0
166
You quoted "/backup/daily/username/homedir/file"

I asume you meant "/backup/cpbackup/daily/username/homedir/file"

If my asumption is correct, this should work:

#!/bin/tcsh -f

set fil = 'filename' # File being copied

foreach user ( `ls /backup/cpbackup/daily` )

if ( $user =~ *.tar.gz ) then
echo "$user is a gzip file... skipping......."
goto ignore
endif

set uC = `ls /home | grep $user`

if ( $user =~ $uC ) then
goto proc
else
echo ""
echo "Can't find /home/$user... skipping......."
goto ignore
endif
proc:

cp -apf /backup/cpbackup/daily/$user/homedir/$fil /home/$user

ignore:
end

echo All done...

exit
BE SURE TO SET FILENAME VARIABLE