c5eaf8e6191baf3c30e04ba30a53ccdf339327dc
[debian/amanda] / docs / howto-wrapper.txt
1
2 Chapter 15. How to use a wrapper
3 Prev  Part III. HOWTOs      Next
4
5 -------------------------------------------------------------------------------
6
7 Chapter 15. How to use a wrapper
8
9
10 Bert de Ridder
11
12 Original text
13
14 Stefan G. Weichinger
15
16 XML-conversion; Updates
17 AMANDA Core Team
18 <sgw@amanda.org>
19
20 Note
21
22 Refer to http://www.amanda.org/docs/howto-wrapper.html for the current version
23 of this document.
24
25 Note
26
27 The script used in this document is not part of the official AMANDA release.
28 The AMANDA core team does not take any responsibility for this script.
29 This is a mini-howto explaining how to control other running tasks on a server
30 where the AMANDA software is used to backup data.
31 Problem : Lots of software is picky about their datafiles being backed up while
32 the files are in use. It sometimes is even necessary to know the state of the
33 datafiles at the moment of backup so that when restoring you know exactly
34 *what* you are restoring. And most of the time there are dependencies between
35 the datafiles as well (for instance, the pure datafiles and the controlfiles of
36 an Oracle database.)
37 The solution is actually quite simple; you just use a custom made backupscript
38 instead of the standard tar command. Inside this tar command, you do some
39 necessary processing before executing the tar command and - if necessary - do
40 some more processing. This way, you can easily stop an Oracle database, tar the
41 files, send them to the tape server and restart the Oracle database. This of
42 course is just an example, anything you can do in a shell script can be done.
43
44   1. Create the script
45      This is the most important step, this script is the work horse of the
46      solution. I've called it /bin/amandatar. You can call it whatever you want
47      though. It's a Perl script, it may not be very pretty code, but it does
48      the job. In the script, an example is given for the backup of a Lotus
49      Notes Domino server.
50
51        #!/usr/bin/perl
52
53        # Tar wrapper for Amanda's tar.
54        #
55
56        use Getopt::Long qw(:config pass_through);
57
58        # Obtain directory and file information from the command line.
59
60        $result = GetOptions (
61         'directory=s' => \$dir,
62         'file=s' => \$file
63        );
64
65        # Check whether Amanda wants to do some administrative task (eg.
66        indexinfo
67        # or obtain the number of bytes to be backed up)
68        # if file = /dev/null it's an administrative task and most of the time,
69        no extra
70        #   processing is necessary.
71
72        # What you see here is just a log of the backup start time, and \96 more
73        important
74        #   the stopping of the domino server
75
76        if ( $file ne '/dev/null' )
77        {
78          if ( $dir eq '/local/notesdata' )
79          {
80            system "echo 'Start backup notes at ' >> /var/lib/amanda/runtime" ;
81            system "date >> /var/lib/amanda/runtime";
82            system ( "/etc/init.d/domino stop >> /var/lib/amanda/runtime" );
83          }
84        }
85
86        # The command line is being 'reconstructed'. Necessary because the
87        GetOptions
88        #   call above has stripped the file and directory information.
89        # This is what I meant with 'ugly'  code ;-)
90
91        while ( $ARGV[0] ne '' )
92        {
93          $val = $ARGV[0] ;
94          unshift ( @NEWARGV, $val, ) ;
95          shift @ARGV;
96        }
97
98        while ( $NEWARGV[0] ne '' )
99        {
100          $val = $NEWARGV[0] ;
101          unshift ( @ARGV, $val ) ;
102          shift @NEWARGV;
103        }
104
105        if ( $dir ne '' )
106        {
107          unshift ( @ARGV, '--directory', $dir );
108        }
109        if ( $file ne '' )
110        {
111          unshift ( @ARGV, '--file', $file );
112        }
113
114        if ( $file ne '/dev/null' )
115        {
116          system "echo 'Backing up directory ' $dir >> /var/lib/amanda/runtime"
117        ;
118        }
119
120        # And finally make sure tar is called :-)
121        #   (path may differ on your installation)
122        unshift ( @ARGV , "/bin/tar" ) ;
123
124        system ( @ARGV ) ;
125
126        # Postprocessing
127        #
128        # If Notes backup was requested, restart the server.
129        # Log the backup end time.
130        #
131
132        if ( $file ne '/dev/null' )
133        {
134          if ( $dir eq '/local/notesdata' )
135          {
136            system ( "/etc/init.d/domino start >> /var/lib/amanda/runtime" );
137            system "echo 'End backup notes at ' >> /var/lib/amanda/runtime" ;
138            system "date >> /var/lib/amanda/runtime";
139          }
140        }
141
142        exit 0;
143
144        # End script
145
146      On some systems it may be necessary to setuid root the script.
147   2. Rebuild AMANDA so that it uses your newly created script.
148      Download the sources, untar them to a directory. I'm sure there are lots
149      of documents already available on how to do this, so I won't go into too
150      much detail. (Refer to Amanda_Installation_Notes).
151      fast path :
152
153        /usr/local/src # tar -xvzf amanda-source.tar.gz
154        /usr/local/src # cd amanda-version
155        /usr/local/src/amanda-version # ./configure \
156          --with-user=amanda \
157          --prefix=/usr/local \
158          --exec-prefix=/usr \
159          --bindir=/usr/bin \
160          --sbindir=/usr/sbin \
161          --libexecdir=/usr/lib/amanda \
162          --with-configdir=/etc/amanda \
163          --with-group=disk \
164          --with-gnutar=/bin/amandatar \
165          --with-gnutar-listdir=/var/lib/amanda/gnutar-lists \
166          --with-tmpdir=/tmp/amanda \
167          --with-smbclient=/usr/bin/smbclient \
168          --mandir=/usr/local/man
169
170      Here, it may be necessary to adjust some paths to match your installation.
171      This setup works on SuSE Linux (also SLES) and MacOSX although you may
172      have to use another binary tar.
173      As you see, you may also "replace" the smbclient if necessary. I haven't
174      yet tested it though. I'll leave it as an exercise for the reader <g>.
175
176        /usr/local/src/amanda-version # make
177        /usr/local/src/amanda-version # make install
178
179      Now proceed as with a "normal" installation.
180
181 -------------------------------------------------------------------------------
182
183 Prev                    Up                           Next
184 Chapter 14. AFS HOWTO  Home  Part IV. Various Information
185