> Service-applications
for the Server |
Last
revision of this document: |
To reduce the number of documents, this document contains installation-instructions for usefull service-applications which need only short instructions.
Shutdown of a computer after a predefined time
Mount directories on a remote computer (configuration in /etc/fstab)
Mount directories on a remote computer (using automount)
Copy data to be backed-up to the tape-cartridge
List data stored on a backup-tape
Restore data from a backup-tape to disk
A computer, which should not be running 24 hours / day can be switched off after a predefined running time.
Operating-system installed ;-).
Installation-instruction:
The file
/etc/rc.d/rc.local
is appended with the following command-lines:
# Automated shutdown of
the computer after a predefined time
# (in minutes) to perform a
controlled unmount of the disks.
shutdown -h 960 &
This
calls the
shutdown
-command
as a background-task during the start-up of the operating-system.
In the
example above,
960
is the time in minutes until the shutdown takes effekt (16 hours in
this example) and
&
is the parameter to perform the command as a background-task.
The file
can only be changed with access-rights as 'root'.
If
the background-task should be stopped, the the user 'root' can use
the commandThat
the change takes effect it is requiered to
.execute
the file
or to restart Linux**/etc/rc.d/rc.local
shutdown
-c
After a
new startup of Linux** it can be checked if shutdown already runs as
a background-task with the following method:
If you try to restart
the computer with keyboard-key-combination Alt-Ctrl-Del, the
message
shutdown
already runningis
displayed.
Directories on another computer (e.g. Server), which where allowed for to be acesses with the Network-File-System (NFS), can be mounted as local directories.
Mounting
directories on a remote computer with this method makes sense only,
if the NFS on the remote computer is already up and running when the
operating-system is started on the workstation. This is due to the
fact that /etc/fstab is read once only during the strartup of the
operating system (Linux**).
If there might be cases that the NFS
on the Server is not up during starting the operating-system on the
workstation or the workstation ist not connected to the network
during startup (e.g. the workstation is a notebook), then using Mount
directories on a remote computer (using automount)
is the better method.
Prerequisites:
Operating-system installed ;-).
A
NFS-Server
is running on the remote computer and directories are allowed to be
accessed.
This can be checked by executing the command showmount
-e 192.168.0.1 (as user 'root' on a command-line).
192.168.0.1 is
the TCP/IP-address of the remote computer.
Linux-workstation - file-struture and users are defined on the computer where the remote directories should be mounted as local directories.
Installation-instruction:
Directories
of the remote computer to be mounted as local directories are defined
by appending the following lines in the file
/etc/fstab:
192.168.0.1:/SMB_Disk/backup_mirror
/_rmt-server/backup_mirror nfs rw,hard,intr 0
0
192.168.0.1:/SMB_Disk/data_backed_up
/
data_backed_up
nfs rw,hard,intr 0 0_rmt-server
/
192.168.0.1:/SMB_Disk/data_not_backed_up
/_rmt-server
/data_not_backed_up
nfs rw,hard,intr 0 0192.168.0.1:/SMB_Disk/finance
/
192.168.0.1:/SMB_Disk/progs_writing
/remote/
nfs rw,hard,intr 0 0_rmt-server/finance
192.168.0.1:/SMB_Disk/progs_honest
/
_rmt-server
/progs_honest
nfs rw,hard,intr 0 0_rmt-server
/progs_writing
nfs rw,hard,intr 0 0
This
allows to access a directory on the remote computer (e.g.
192.168.0.1:/SMB_Disk/backup_mirror
)
like are local directory (with the name /
in the above configuration). _rmt-server
/backup_mirror
Additional hints:
The
file can only be changed with access-rights as 'root'
.
That
the change takes effect it is requiered to restart Linux**.
For
security-reasons the access-rights do not allow the user 'root' to
access the mounted directories. To access the mounted directories it
is necessary to log on with a user-name which has access to the
mounted directories.
Test:
Logged
on as a user with access-right to the directories the command
dir
/remote/server/data_backed_up
is
issued and the content of the directory should be displayed.
Using
a editor a file called
.mounttest
is
created on the directory
/remote/server/data_not_backed_up
.
After
successfully creating the file it can be deleted with the command
rm
/remote/server/data_backed_up/mounttest
Directories on another computer (e.g. Server), which where allowed for to be acesses with the Network-File-System (NFS), can be mounted as local directories.
Mounting
directories with this method is a safe one but less performant.
If
it can be taken for sure that the NFS is running on the Server when
the operating-system on the workstation is started-up, then the
method Mount
directories on a remote computer (configuration in /etc/fstab)
is faster and more efficient.
Prerequisites:
Operating-system installed ;-).
A
NFS-Server
is running on the remote computer and directories are allowed to be
accessed.
This can be checked by executing the command
showmount -e 192.168.0.1 (as user 'root' on a
command-line).
192.168.0.1 is the TCP/IP-address of the remote
computer.
Linux-workstation – file-struture and users are defined on the computer where the remote directories should be mounted as local directories.
Installation-instruction:
Automatic
starting of the automount-demon
To
configure automatic startup the command
ntsysv
is executed on the
command-line.
On
the following 'Services'-menu the selection
[ ] autofs is marked with the space-bar and the and
confirmed with the OK-button.
Configuration
of the 'Master'-file
The
file /etc/auto.master will be append with the following lines:
/
_rmt-server
/etc/auto.server --timeout=60
This
defines the local directory (
/remote/server
)
and the file with the 'Indirect Maps' (/etc/auto.server
)
where the references to the directories on the remote computer
(Server) will be defined.
Please take care not to change or delete
existing configuration-lines !!
Configuration
of the 'Indirect-Map'-file
(
/etc/auto.server
in this example)
The
file /etc/auto.server
will contain the following configuration-lines:
backup_mirror
-browse,rw,soft,intr
192.168.0.1:/SMB_Disk/backup_mirror
data_backed_up
-browse,rw,soft,intr
192.168.0.1:/SMB_Disk/dat
a_backed_up
data_not_backed_up
-browse,rw,soft,intr 192.168.0.1:/SMB_Disk/
data_not_backed_up
finance
-browse,rw,soft,intr 192.168.0.1:/SMB_Disk/finance
progs_honest
-browse,rw,soft,intr 192.168.0.1:/SMB_Disk/progs_
honest
progs_writing -browse,rw,soft,intr
192.168.0.1:/SMB_Disk/progs_
writing
This
file in conjunction with
/etc/auto.master
mounts the remote directories (e.g.
192.168.0.1:/SMB_Disk/dat
)
to the subdirectory (e.g.
a_backed_up
data_backed_up
)
under the directory
/remote/server
(defined in
/etc/auto.master
).Please
take care not to change or delete existing configuration-lines !!
Additional hints:
The
file can only be changed with access-rights as 'root'
.
That
the change takes effect it is requiered to restart the service with
the command
/etc/init.d/autofs
reload or to
.restart
Linux**
For
security-reasons, the access-rights do not allow the user 'root' to
access the mounted directories. To access the mounted directories it
is necessary to log on with a user-name which has access to the
mounted directories.
Test:
Logged
on as a user with access-right to the directories the command
dir
/remote/server/data_backed_up
is issued and the
content of the directory should be displayed.
Using
a editor a file called
.mounttest
is created on the directory
/remote/server/data_not_backed_up
.
After
successfully creating the file it can be deleted with the command rm
/remote/server/data_backed_up/mounttest
This
part introduces a script, which copies all data from the directories
/SMB_Disk/data_backed_up
,
/
and SMB_Disk
/finance/
to the directory SMB_Disk
/progs_writing/
first and to a backup-tape thereafter.SMB_Disk
/backup_mirror
Prerequisites:
Operating-system installed ;-).
The file- and user-structure as described in the document 'Linux-Server - file-structure and users' is already implemented on the Server.
Installation-instruction:
Create a
file named /SMB_Disk/data_backed_up/system_scripts/linux/backup.sh
and edit it with the following commands.
(For
an instruction how to copy the following text to a file please follow
this link.)
#!/bin/sh
###################
###
PURPOSE: Copies all directories with files to be backed-up
### to
the dedicated directory and to a tape
thereafter
###################
#
echo -n "Starting
backup to tape ...."
#
# copy data to be copied to the
directory /SMB_Disk/backup-mirror
echo -n "Copy data to
directory backup_mirror ..."
#
# Delete existing data by
deleting whole directory backup_mirror
# and re-create directory
backup_mirror
rm -fr /SMB_Disk/backup_mirror
mkdir
/SMB_Disk/backup_mirror
cp -R
/SMB_Disk/data_backed_up /#
# Copy data
to be backed_upSMB_Disk/
backup_mirrorcp
-R /SMB_Disk/finance /
#SMB_Disk/
backup_mirrorcp
-R /SMB_Disk/progs_writing /
SMB_Disk/
backup_mirror#
chgrp -R admin
/SMB_Disk/backup_mirror
# Change access-rights so, that only users belonging to group
'admin' are allowed to read (only)chmod
-R 440 /SMB_Disk/backup_mirror
#
Copy data to backup-tape
echo -n "Copy data to backup-tape
..."
mt -f /dev/st0 rewind
tar -cvMpf /dev/st0
/SMB_Disk/backup_mirror
mt -f /dev/st0 offline
echo "Data
backed-up to tape; please remove the tape ..."
#
#
#
Uncomment the 'shutdown' command
# if the backup is run at the
end of day
# and the computer should be switched off
#
shutdown -h now
### End of scripts ###
To
protect the just created file against erratical change, give only
read- and execution-rights to the owner (i.e. Root) by entering the
following command at the terminal:
chmod
500 SMB_Disk/data_backed_up/system_scripts/linux/backup.sh
Defining the start-time:
Starting
at the begin of day
The
previous script will be executed by appending the following lines to
the file /etc/rc.d/rc.local
:
# Copy selected data to
the directory /SMB_Disk/backup_mirror
# and furtheron to the
backup-tape (dev/st0)
/SMB_Disk/data_backed_up/system_scripts/linux/backup.sh &
This
causes, that the script to backup data to the backup-tape will be
called as background-task when the operating system is started.
Starting
at a defined time
The
previous script will be executed by using crontab. The following
statement is added to the file /etc/crontab
:
SHELL=/bin/bash
.
. .
. . .
42
4
1 * * root run-parts /etc/cron.monthly
# Backup data to
tape (at 23:30 in this example)
# using the script in file
'backup.sh'.
0 23 *
* * root /SMB_Disk/data_backed_up/system_scripts/linux/backup.sh
. . .
.
. .
This
causes, that the script to backup data to the backup-tape will be
called at the predefined time.
Additionally, a 'shutdown' can be
performed as soon as the backup is complete.
Additional hints:
The
file can only be changed with access-rights as 'root'.
.
That the
change takes effect it is requiered to execute
the file
(if the backup is performed at start-up)
or to restart Linux** /etc/rc.d/rc.local
Test:
After a
restart of the computer, data to be backed-up ist copied to the
directory
first and written to the backup-tape thereafter.SMB_Disk
/backup_mirror
If
the data was written to the tape correctly can be checked as
described under List
data stored on a backup-tape.
Additional references:
List data stored on a backup-tape |
This script shows the contents of a tape. |
Restore data from a backup-tape to disk |
This script restores all or selected files from a backup-tape back to the harddisk. |
.
This part introduces the command to list the files backed-up on a tape.
Prerequisites:
Operating-system installed ;-).
Files
must be backed-up with the command 'tar'.
How to inspect, which
kind of archives a tape contains is described under
'http://nic.phys.ethz.ch/readme/80#6'.
Command-instruction:
Open a
Terminal-window and enter the following command:
tar tvf /dev/st0
If
you want to list just the files of a directory, give the the complete
path of the directory.
The following command is an example:
tar tvf /dev/st0
SMB_Disk/backup_mirror/data_backed_up/Download/jdk_jre/*
Additional hints:
The
command can only be executed with access-rights as 'root'.
If the
tape contains numerous files, it is advisable to open a
Terminal-window under the GUI. The Terminal-window is not restricted
on lines to display and therefore the display of a file-name is not
scrolled out of the screen after a while.
Rewind the tape (command
mt -f /dev/st0
rewind
) before listing the files.
.
You
need some patience to see a result as the tape has to be winded
forward completely to check the contents of the tape
Test:
Watch if
the selected files are listed on the Terminal-Window.
This part introduces the command to list the files backed-up on a tape.
Prerequisites:
Operating-system installed ;-).
Files
must be backed-up with the command 'tar'.
How to inspect, which
kind of archives a tape contains is described under
'http://nic.phys.ethz.ch/readme/80#6'.
Command-instruction:
Open a
Terminal-window and enter the following commands:
Rewind
the tape:
mt -f /dev/st0 rewind
Go to
the top-directory if you want to restore to the original
directory/ies;
if you want to restore to another directory -
change to this directory:
cd /
Issue
the command to restore the complete set of files from the tape:
tar xvf /dev/st0
If you
want to restore just the files of a directory, give the the complete
path of the directory.
The following command is an example:
tar xvf /dev/st0
SMB_Disk/backup_mirror/data_backed_up/Download/jdk_jre/*
If you
want to restore just a single file, give the filename including the
complete path.
The following command is an example:
tar xvf /dev/st0
SMB_Disk/backup_mirror/data_backed_up/office/invoices/570021.sxw
Additional hints:
The
command can only be executed with access-rights as 'root'.
If the
tape contains numerous files, it is advisable to open a
Terminal-window under the GUI. The Terminal-window is not restricted
on lines to display and therefore the display of a file-name is not
scrolled out of the screen after a while.
.
If
you restore just singele directories or files, you need some patience
to see a result as the tape has to be winded forward until the
selected files or directories have been found
Test:
Check if
the selected files are in the correct directory on the harddisk.