Wildcard Characters in Filenames: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
m (What if there are shell metacharacters in the backed-up filenames? moved to Amrecover: shell metacharacters in the filenames)
(not shell meta but wildcard characters)
Line 2: Line 2:




If you have backed up files with shell metacharacters as part of the filename, and you are using Gnu tar as part of your Amanda backup process, you may notice that you can no longer pull the files out. The symptoms are:
If you have backed up files with wildcard characters as part of the filename, and you are using gnutar as part of your Amanda backup process, you may notice that you can no longer pull the files out. The symptoms are:


   amrecover> add *asid=\[101\]*
   amrecover> add *asid=\[101\]*
   Added /joe_asid=[101].gz
   Added /joe_asid=[101].gz
   amrecover> extract
   amrecover> extract
   Extracting files using tape drive /dev/nst0 on  host xyz.com.
   Extracting files using tape drive /dev/nst0 on  host amandahost.example.com.
   The following tapes are needed: big1
   The following tapes are needed: big1
   Restoring files into directory /tmp
   Restoring files into directory /tmp
Line 18: Line 18:
The solution can be one of a number of things:
The solution can be one of a number of things:


1. Try to make Gnu tar treat shell metacharacters
1. Try to make gnutar treat wildcard characters
(like [ and ] and *) as normal characters. I'm not sure this is possible, and I haven't tried.
(like [ and ] and *) as normal characters. I'm not sure this is possible, and I haven't tried.


2. Edit the amrecover source code to make it escape shell metacharacters.
2. Edit the amrecover source code to make it escape wildcard characters.


3. Use amrestore instead of amrecover so that you can escape the filenames you're interested in, eg:
3. Use amrestore instead of amrecover so that you can escape the filenames you're interested in, e.g.:


   $ mt -f /dev/nst0 rewind
   $ mt -f /dev/nst0 rewind
   $ amrestore -p /dev/nst0 \
   $ amrestore -p /dev/nst0 \
     hostname.myowncompany.com \
     client1.example.com \
     /backed/up/directory | tar -xvf - '*\[101\]*'
     '/backed/up/directory$' | tar -xpvf - './joe_asid=\[101\].gz'
 
Or more specifically, the value you could pass to Gnu tar would be:
 
  'joe_asid\[101\].gz'

Revision as of 22:09, 9 December 2005

--- This text was originally contributed to the AMANDA-FAQ-O-Matic by [email protected]. ---


If you have backed up files with wildcard characters as part of the filename, and you are using gnutar as part of your Amanda backup process, you may notice that you can no longer pull the files out. The symptoms are:

 amrecover> add *asid=\[101\]*
 Added /joe_asid=[101].gz
 amrecover> extract
 Extracting files using tape drive /dev/nst0 on  host amandahost.example.com.
 The following tapes are needed: big1
 Restoring files into directory /tmp
 Continue? [Y/n]: y
 Load tape big1 now
 Continue? [Y/n]: y
 tar: ./joe_asid=[101].gz: Not found in archive
 tar: Error exit delayed from previous errors

The solution can be one of a number of things:

1. Try to make gnutar treat wildcard characters (like [ and ] and *) as normal characters. I'm not sure this is possible, and I haven't tried.

2. Edit the amrecover source code to make it escape wildcard characters.

3. Use amrestore instead of amrecover so that you can escape the filenames you're interested in, e.g.:

 $ mt -f /dev/nst0 rewind
 $ amrestore -p /dev/nst0 \
    client1.example.com \
    '/backed/up/directory$' | tar -xpvf - './joe_asid=\[101\].gz'