[SGVLUG] runlevel 1 backup

Claude Felizardo cafelizardo at gmail.com
Sat Jul 5 14:27:50 PDT 2008


On Sat, Jul 5, 2008 at 1:53 PM, Don Saxton <dsaxton at pacbell.net> wrote:
>
> I have a script for a tar backup. It should be run at init 1 on this
> headless machine with ssh access.
>
>
> Obviously there is no sshd at runlevel 1. So how can I perform this
> sequence: telinit 1;backup; telinit 3 ?

Are you saying you need to be able to initiate this remotely implying
that the machine is at level 3?

You could create a special user and use sshkeys to trigger a script in
an sshconfig file that does the following:

1) changes the runlevel in your /etc/inittab to 1.
2) enables a script in /etc/rc.d/rc1.d (or equiv) see below for details.
3) telinit 0 to reboot.

Machine reboots to level 1, runs the script which does the following:

a) restores your /etc/inittab so it will reboot into level 3
b) disables itself so when it reboots, it won't keep rebooting
c) run the backup
d) reboot to level 3


If possible, protect ssh access to this user with a passphrase.

BTW, why level 1?  Is it so you can make a consistent backup of your
OS?  What about an extra OS partition that you can boot one or the
other.   That way you can boot one partition and use it to fsck the
other, make backups, try out new distros, etc.  This is what TiVo does
for handling updates.

What about playing with /etc/inittab so if you hit ctl-alt-del it will
go to level 1, do the backup then reboot to default 3.

On most of my machines, I have ctl-alt-del set to do a shutdown.  This
allows people at work or at home to shut the machines down w/o having
to know the password.  They've got physical access and this lets them
do an orderly shutdown instead of yanking the power if I'm not there.

Hey, isn't there a mechanism for telling the system to reboot using a
specific entry in /etc/lilo?  Is there also a way to tell the system
what run level as well?  Then you can have multiple entries in your
/etc/lilo.conf that run either the backup stuff or normal.  That would
let you pick it at boot time, default is level 3, and the sshkey
config file would let you pick the backup stuff remotely.


claude


More information about the SGVLUG mailing list