Amanda-Users

Re: Checking for missing files.

2002-08-27 12:51:39
Subject: Re: Checking for missing files.
From: Jon LaBadie <jon AT jgcomp DOT com>
To: Trevor Fraser <trevor AT systematic.co DOT za>
Date: Tue, 27 Aug 2002 12:25:50 -0400
On Tue, Aug 27, 2002 at 05:30:58PM +0200, Trevor Fraser wrote:
> Hi Jon.
> 
> Thanks for the reply.
> 
> My objective is when someone accidentally deletes files and doesn't know
> what file they were, to compare what Amanda has on tape and what is on the
> file system to see what is different, so I don't have to manually search the
> tape and the file system to see what is missing and what to restore.
> 
> Thanks, Trevor.

Ahh, then probably the regular indexes will be sufficient.

I presume you are "recording", then you have an "indexdir" defined.
In that indexdir will be subdirs for each host.
Under the host dir will be subdirs with names based on the disklist entries.
In these names the "/" are replaced with "_".

My approach would be to make a list of everything the user currently has
and compare it to what the index shows is on tape.  Assume the user is "shmo"
As root:

   cd ~shmo/..  # one level above shmo
   find shmo > /tmp/shmo-current
   # or two levels and do a   find home/shmo
   sort -o /tmp/shmo-current /tmp/shmo-current

   cd <amanda-index-dir-for-shmo's-filesystem>
   # note all the backups since the last level 0.
   # in my case that would be 20020823_0.gz
   # 20020824_1.gz 20020826_1.gz 20020827_2.gz

   for f in 20020823_0.gz 20020824_1.gz 20020826_1.gz 20020827_2.gz
   do
        gzip -dc < $f | grep /shmo/ | sed 's,/$,,'
   done | sort | uniq > /tmp/shmo-tape

   # or the command might look for /home/shmo if appropriate
   # the sed is to remove any trailing "/"s on dir names that my indexes
   # have, but the find does not.

   # now you may have to edit one or the other file to make the leading
   # part of each line the same  For example, the find may not have a "/"
   # at the start or might need "/home/" added to one file or deleted
   # from the other.

Now you have two sorted lists, what is in shmo's directory tree currently
and what is on tape in at least one of the most recent backup set.
Of course the "for f in ..." loop could have been done on all index files
to go further back.

To compare them use the comm command:

    # files on tape but not in current dir tree
    comm -13 /tmp/shmo-current /tmp/shmo-tape

    # files in current dir tree, not on tape
    comm -23 /tmp/shmo-current /tmp/shmo-tape

    # files in both
    comm -12 /tmp/shmo-current /tmp/shmo-tape

Another approach is to amrecover the entire /home/shmo tree in some tmp dir.
Then do a "dircmp" of shmos' current tree with the tmp tree.  Then you already
have the files on disk and can simply copy them.

Hope these make sense and help.  Maybe someone else has alternative approaches.

-- 
Jon H. LaBadie                  jon AT jgcomp DOT com
 JG Computing
 4455 Province Line Road        (609) 252-0159
 Princeton, NJ  08540-4322      (609) 683-7220 (fax)

<Prev in Thread] Current Thread [Next in Thread>