Gentoo Archives: gentoo-user

From: Allan Gottlieb <gottlieb@×××.edu>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Performing a backup during the boot sequence
Date: Wed, 26 May 2010 16:39:36
Message-Id: yu9632ar52y.fsf@nyu.edu
In Reply to: Re: [gentoo-user] Performing a backup during the boot sequence by Daniel Troeder
1 At Wed, 26 May 2010 17:17:45 +0200 Daniel Troeder <daniel@×××××××××.com> wrote:
2
3 > On 05/26/2010 12:30 AM, Allan Gottlieb wrote:
4 >> For quite a while I have used the following steps to perform a
5 >> "single-user backup"
6 >>
7 >> 1. Boot to single user mode via the grub command
8 >> kernel /boot/vmlinuz root=/dev/sda6 single
9 >>
10 >> 2. Type in the root password.
11 >>
12 >> 3. Execute a single command
13 >> /usr/local/sbin/ajg-backup-init-3
14 >> which does the backup and then executes
15 >> init 3
16 >>
17 >> 4. This gets me to multi-user mode.
18 >>
19 >> I would like to automate this so that booting directly to multi-user
20 >> mode via
21 >> kernel /boot/vmlinuz root=/dev/sda6
22 >>
23 >> All I need to do is to execute the single command
24 >> /usr/local/sbin/ajg-backup-init-3
25 >> at the right moment.
26 >> This didn't seem hard; I want it after everything in boot but before
27 >> everything currently in default. So I was going to put it in
28 >> default with a "before *" in depend()
29 >>
30 >> Reading the gentoo handbook chapter B4.d "Writing Init Scripts"
31 >> I find two comments criticizing this approach
32 >>
33 >> 1. "You can also use the "*" glob [argument to before] to catch all
34 >> services in the same runlevel, although this isn't advisable".
35 >>
36 >> 2. "Note: Make sure that --exec actually calls a service and not just a
37 >> shell script that launches services and exits -- that's what the
38 >> init script is supposed to do."
39 >>
40 >> I can see problems with multiple "before *" directives, but no other
41 >> script has one so I think I would be OK with my "before *".
42 >>
43 >> Criticism 2 has me concerned since my backup routing is indeed a shell
44 >> script that exits. Indeed, my backup is not really a service so I am
45 >> worried that I shouldn't be using an initscript at all.
46 >>
47 >> Any advice/comments would be welcome.
48 >>
49 > You could create a LVM-snapshot of the partition/data you wish to backup
50 > at "before *" or inside "boot" and then later run the backup on the
51 > mounted snapshot, removing it afterwards.
52
53 Thanks, but I am not trying to minimize the boot time. The disk to disk
54 dumps are fast enough (I do the slower copy to a remote site after
55 logged in). I am just trying to have the dump done at the right point
56 in the boot sequence without manually going into single user mode. If I
57 could automate the snapshot, I could automate the dump.
58
59 Indeed rereading the gentoo manual, I see that the requirement that you
60 invoke a service and not a script that exits, applies only to
61 start-stop-daemon, so I will just try to invoke my script directly from
62 the init script.
63
64 allan