Tuesday, May 19, 2009

Perform Client-Server Cross-Platform Backups with Bacula (Part 2)

Database Setup
Now that you've modified the configuration files to suit your needs, use Bacula's scripts to create and define the database tables that it will use.
To set up for MySQL:
# cd /usr/ports/sysutils/bacula/work/bacula-1.32c/src/cats

# ./grant_mysql_privileges

# ./create_mysql_database

# ./make_mysql_tables

If you have a password set for the MySQL root account, add -p to these commands and you will be prompted for the password. You now have a working database suitable for use by Bacula.
Testing Your Tape Drive
Some tape drives are not standard. They require their own proprietary software and can be temperamental when used with other software. Regardless of what software it uses, each drive model can have its own little quirks that need to be catered to. Fortunately, Bacula comes with btape, a handy little utility for testing your drive.
My tape drive is at /dev/sa1. Bacula prefers to use the non-rewind variant of the device, but it can handle the raw variant as well. If you use the rewinding device, then only one backup job per tape is possible. This command will test the non-rewind device /dev/nrsa1:
# /usr/local/sbin/btape -c /usr/local/etc/bacula-sd.conf /dev/nrsa1

Running Without Root
It is a good idea to run daemons with the lowest possible privileges. The Storage Daemon and the Director Daemon do not need root permissions. However, the File Daemon does, because it needs to access all files on your system.
In order to run daemons with nonroot accounts, you need to create a user and a group. Here, I used vipw to create the user. I selected a user ID and group ID of 1002, as they were unused on my system.
bacula:*:1002:1002::0:0:Bacula Daemon:/var/db/bacula:/sbin/nologin

I also added this line to /etc/group:
bacula:*:1002:

The bacula user (as opposed to the Bacula daemon) will have a home directory of /var/db/bacula, which is the default location for the Bacula database.
Now that you have both a bacula user and a bacula group, you can secure the bacula home directory by issuing this command:
# chown -R bacula:bacula /var/db/bacula/

Starting the Bacula Daemons
To start the Bacula daemons on a FreeBSD system, issue the following command:
# /usr/local/etc/rc.d/bacula.sh start

To confirm they are all running:
# ps auwx | grep bacula



root 63416 0.0 0.3 2040 1172 ?? Ss 4:09PM 0:00.01

/usr/local/sbin/bacula-sd -v -c /usr/local/etc/bacula-sd.conf

root 63418 0.0 0.3 1856 1036 ?? Ss 4:09PM 0:00.00

/usr/local/sbin/bacula-fd -v -c /usr/local/etc/bacula-fd.conf

root 63422 0.0 0.4 2360 1440 ?? Ss 4:09PM 0:00.00

/usr/local/sbin/bacula-dir -v -c /usr/local/etc/bacula-dir.conf

Using the Bacula Console
The console is the main interface through which you run jobs, query system status, and examine the Catalog contents, as well as label, mount, and unmount tapes. There are two consoles available: one runs from the command line, and the other is a GNOME GUI. I will concentrate on the command-line console.
To start the console, I use this command:
# /usr/local/sbin/console -c /usr/local/etc/console.conf

Connecting to Director laptop:9101

1000 OK: laptop-dir Version: 1.32c (30 Oct 2003)

*

You can obtain a list of the available commands with the help command. The status all command is a quick and easy way to verify that all components are up and running. To label a Volume, use the label command.
Bacula comes with a preset backup job to get you started. It will back up the directory from which Bacula was installed. Once you get going and have created your own jobs, you can safely remove this job from the Director configuration file.
Not surprisingly, you use the run command to run a job. Once the job runs, the results will be sent to you via email, according to the Messages resource settings within your Director configuration file.
To restore a job, use the restore command. You should choose the restore location carefully and ensure there is sufficient disk space available.
It is easy to verify that the restored files match the original:
# diff -ruN \

/tmp/bacula-restores/usr/ports/sysutils/bacula/work/bacula-1.32c \

/usr/ports/sysutils/bacula/work/bacula-1.32c

#

Creating Backup Schedules
For my testing, I wanted to back up files on my Windows XP machine every hour. I created this schedule:
Schedule {

Name = "HourlyCycle"

Run = Full 1st sun at 1:05

Run = Differential 2nd-5th sun at 1:05

Run = Incremental Hourly

}

Any Job that uses this schedule will be run at the following times:
• A full backup will be done on the first Sunday of every month at 1:05 AM.
• A differential backup will be run on the 2nd, 3rd, 4th, and 5th Sundays of every month at 1:05 AM.
• Every hour, on the hour, an incremental backup will be done.
Creating a Client-only Install
So far we have been testing Bacula on the server. With the FreeBSD port, installing a client-only version of Bacula is easy:
# cd /usr/ports/sysutils/bacula

# make -DWITH_CLIENT_ONLY install

You will also need to tell the Director about this client by adding a new Client resource to the Director configuration file. You will also want to create a Job and FileSet resource.
When you change the Bacula configuration files, remember to restart the daemons:
# /usr/local/etc/rc.d/bacula.sh restart

Stopping the Storage daemon

Stopping the File daemon

Stopping the Director daemon

Starting the Storage daemon

Starting the File daemon

Starting the Director daemon

#

Perform Client-Server Cross-Platform Backups with Bacula (Part 1)

Bacula is a powerful, flexible, open source backup program. .
Having problems finding a backup solution that fits all your needs? One that can back up both Unix and Windows systems? That is flexible enough to back up systems with irregular backup needs, such as laptops? That allows you to run scripts before or after the backup job? That provides browsing capabilities so you can decide upon a restore point? Bacula may be what you're looking for.
Introducing Bacula
Bacula is a client-server solution composed of several distinct parts:

Director
The Director is the most complex part of the system. It keeps track of all clients and files to be backed up. This daemon talks to the clients and to the storage devices.

Client/File Daemon
The Client (or File) Daemon runs on each computer which will be backed up by the Director. Some other backup solutions refer to this as the Agent.

Storage Daemon
The Storage Daemon communicates with the backup device, which may be tape or disk.

Console
The Console is the primary interface between you and the Director. I use the command-line Console, but there is also a GNOME GUI Console.
Each File Daemon will have an entry in the Director configuration file. Other important entries include FileSets and Jobs. A FileSet identifies a set of files to back up. A Job specifies a single FileSet, the type of backup (incremental, full, etc.), when to do the backup, and what Storage Device to use. Backup and restore jobs can be run automatically or manually.
Installation
Bacula stores details of each backup in a database. You can use either SQLite or MySQL, and starting with Bacula Version 1.33, PostgreSQL. Before you install Bacula, decide which database you want to use.
The existing Bacula documentation provides detailed installation instructions if you're installing from source. To install instead the SQLite version of the FreeBSD port:
# cd /usr/ports/sysutils/bacula

# make install

Or, if you prefer to install the MySQL version:
# cd /usr/ports/sysutils/bacula

# make -DWITH_MYSQL install

Configuration Files
Bacula installs several configuration files that should work for your environment with few modifications.
File Daemon on the backup client
The first configuration file, /usr/local/etc/bacula-fd.conf, is for the File Daemon. This file needs to reside on each machine you want to back up. For security reasons, only the Directors specified in this file will be able to communicate with this File Daemon. The name and password specified in the Director resource must be supplied by any connecting Director.
You can specify more than one Director { } resource. Make sure the password matches the one in the Client resource in the Director's configuration file.
The FileDaemon { } resource identifies this system and specifies the port on which it will listen for Directors. You may have to create a directory manually to match the one specified by the Working Directory.
Storage Daemon on the backup server
The next configuration file, /usr/local/etc/bacula-sd.conf, is for the Storage Daemon. The default values should work unless you need to specify additional storage devices.
As with the File Daemon, the Director { } resource specifies the Director(s) that may contact this Storage Daemon. The password must match that found in the Storage resource in the Director's configuration file.
Director on the backup server
The Director's configuration is by necessity the largest of the daemons. Each Client, Job, FileSet, and Storage Device is defined in this file.
In the following example configuration, I've defined the Job Client1 to back up the files defined by the FileSet Full Set on a laptop. The backup will be performed to the File storage device, which is really a disk located at laptop.example.org.

# more /usr/local/etc/bacula-dir.conf



Director {

Name = laptop-dir

DIRport = 9101

QueryFile = "/usr/local/etc/query.sql"

WorkingDirectory = "/var/db/bacula"

PidDirectory = "/var/run"

Maximum Concurrent Jobs = 1

Password = "lLftflC4QtgZnWEB6vAGcOuSL3T6n+P7jeH+HtQOCWwV"

Messages = Standard

}

Job {

Name = "Client1"

Type = Backup

Client = laptop-fd

FileSet = "Full Set"

Schedule = "WeeklyCycle"

Storage = File

Messages = Standard

Pool = Default

Write Bootstrap = "/var/db/bacula/Client1.bsr"

Priority = 10

}

FileSet {

Name = "Full Set"

Include = signature=MD5 {

/usr/ports/sysutils/bacula/work/bacula-1.32c

}



# If you backup the root directory, the following two excluded

# files can be useful

#

Exclude = { /proc /tmp /.journal /.fsck }

}

Client {

Name = laptop-fd

Address = laptop.example.org

FDPort = 9102

Catalog = MyCatalog

Password = "laptop-client-password"

File Retention = 30 days

Job Retention = 6 months

AutoPrune = yes

}

# Definition of file storage device

Storage {

Name = File

Address = laptop.example.org

SDPort = 9103

Password = "TlDGBjTWkjTS/0HNMPF8ROacI3KlgIUZllY6NS7+gyUp"

Device = FileStorage

Media Type = File

}

Note that the password given by any connecting Console must match the one here.

Sunday, May 17, 2009

六点策略建议大力发展Linux

随着Linux以及开源软件对世界软件产业格局的改变,随着开源软件向主流软件地位的发展,软件 产业重新洗牌过程中蕴育着千载难逢的机遇。我国既有的软件产业发展基础和巨大的国内软市场,为我们抓住这个难得的产业发展机遇提供了实力和条件,发展Linux以及开源软件将成为我国软件产业向更高层次跃进的突破口。

在此,我们提出以下大力发展Linux的策略建议:
(1) 制定标准和规范,彻底解决兼容性问题
目前各种版本Linux的差异、在此基础上开发的应用软件之间的差异以及与各种基于Windows的 各类硬件设备的接口的差异,是阻碍Linux软件发展的最主要问题。国家要加快Linux标准的制定,规范Linux及基于Linux的数据库软件、中间件以及各类应用软件的开发,彻底解决各类应用软件的接口。

(2)兼容性问题。
加强开源规则及法律的研究,保证国内Linux产业的良性发展 处理好作为自有软件的Linux和基于Linux开发的软件之间的知识产权关系,快速推进自主知识产 权的Linux软件发展的同时,继续加强开源规则及法律的研究,保证国内Linux产业的良性发展。

(3)建设开放的公共平台,促进技术创新
加大资金投入,建立为Linux软件产业发展提供技术支撑的公共、开放、国际化的开发平台,形成高效灵活的产业服务机制,引导企业合作开发、利益共享,促进产业的技术创新水平。

(4)细分市场,选择重点行业和省市占领应用市场
积极推广国产Linux软件,选择有条件的机构和重点行业在电子政务、行业信息化和企业信息化等方面开展Linux国产软件产业化试点。鼓励有条件的地方建立有特色的国家Linux产业化基地。

(5)完善Linux产业链,全方位推动Linux产业发展
引导ISV(独立软件商)向Linux转型,形成从操作系统、数据库、中间件到各类应用软件的完善的Linux产业链。只有形成完善的产业链,才能使Linux系列软件得到真正的广泛应用。

(6)组建国家层次上的开放源代码组织,加强国际合作
推动企业和行业协会组建国内Linux开放源代码社区组织,积极参与国际上有影响力的开放源代码组织,制定国产Linux技术发展路线,控制国内Linux软件发展的主导权。鼓励并帮助国内开源社区及国内Linux企业参与国际合作,创造良好的国际交流环境与渠道等

Sunday, May 10, 2009

How to allow access to the mail server by individual domains - Sendmail

The access database (normally in /etc/mail/access) allows a mail administrator to administratively allow access to the mail server by individual domains. Each database entry consists of a domain name or network number as the key and an action as the value.

Keys can be a fully or partly qualified host or domain name such as host.subdomain.domain.com, subdomain.domain.com, or domain.com. The last two forms match any host or subdomain under the specified domain.

Keys can also be a network address or subnetwork, e.g., 205.199.2.250, 205.199.2, or 205.199. The latter two forms match any host in the indicated subnetwork. Lastly, keys can be user@host.domain to reject mail from a specific user.

Values can be REJECT to refuse connections from this host, DISCARD to accept the message but silently discard it (the sender will think it has been accepted), OK to allow access (overriding other built-in checks), RELAY to allow access including relaying SMTP through your machine, or an arbitrary message to reject the mail with the customized message.

For example, a database might contain:
abc.com REJECT
sendmail.org RELAY
spam@buyme.com 550 Spammer

to reject all mail from any host in the abc.com domain, allow any relaying to or from any host in the sendmail.org domain, and reject mail from spam@buyme.com with a specific message.

Note that the access database is a map and just as with all maps, the database must be generated using makemap. For example: makemap hash /etc/mail/access < /etc/mail/access

Tuesday, May 5, 2009

Iptraf - Ncurses based LAN monitor

IPTraf is a network monitoring utility for IP networks. It intercepts packets on the network and gives out various pieces of information about the current IP traffic over it. Information returned by IPTraf include:

* Total, IP, TCP, UDP, ICMP, and non-IP byte counts
* TCP source and destination addresses and ports
* TCP packet and byte counts
* TCP flag statuses
* UDP source and destination information
* ICMP type information
* OSPF source and destination information
* TCP and UDP service statistics
* Interface packet counts
* Interface IP checksum error counts
* Interface activity indicators
* LAN station statistics

IPTraf can be used to monitor the load on an IP network, the most used types of network services, the proceedings of TCP connections, and others.

Installation:
OpenSuSe 11.1 - here
OpenSuSe 11.0 - here

Others:
Download the latest version. Once you have it downloaded, move it to /usr/local/src and untar it by running: # tar -zxvf iptraf-3.0.0.tar.gz

To compile and install, just change to the iptraf-3.0.0 top-level directory and type:./Setup
This will automatically compile and install the software and install the binaries into /usr/local/bin so make sure that directory is in your PATH.

The traditional way to do it ..

cd src
make clean
make
make install

Precompiled binaries are available in the iptraf-3.0.0.i386.bin.tar.gz file. This contains no source code and is expected to run on Intel x86 Linux with the GNU C Library 2.1 or later.

Once you have it installed, start it up by typing /usr/local/bin/iptraf as root. An ncurses based main menu will come up on your screen and you will have a list of options that you can select.

Sunday, May 3, 2009

Making a bootable OpenBSD install CD 4.5

On the date of the release of the newest version of OpenBSD you have a few choices concerning install media.

Here is the shell script command to download and create ISO file for OpenBSD


#!/usr/local/bin/bash
#
## Calomel.org -- Making a bootable OpenBSD CD
## calomel_make_boot_cd.sh
#
arch="amd64" # Architecture, Depend on you machine type
version="4.5" # OS version
#
echo "building the environment"
mkdir -p /tmp/OpenBSD/$version/$arch
cd /tmp/OpenBSD/$version/$arch
#
echo "getting the release files"
wget --passive-ftp --reject "*iso" ftp://ftp.openbsd.org/pub/OpenBSD/$version/$arch/*
#
echo "building the ISO"
cd /tmp/OpenBSD
mkisofs -r -no-emul-boot -b $version/$arch/cdbr -c boot.catalog -o OpenBSD.iso /tmp/OpenBSD/
#
echo "burning the bootable cd"
nice -18 cdrecord -eject -v speed=32 dev=/dev/rcd0c:0,0,0 -data -pad /tmp/OpenBSD/OpenBSD.iso
#
echo "DONE."
#
 
Custom Search