понедельник, 27 декабря 2010 г.

Скрипт для задания ACL для папок, имена которых прсутсвуют в именах группы

У меня в АД есть отдельная OU в которой присутсвуют группы которым выданы права на ресурсы: принтеры, общие папки, доступ в интернет, удаленный доступ, доступ к объектам АД.
Для групп, которым выдается разрешение на папку присваивается имя:
dl_atdfs_ИМЯПАПКИ_ТИПРАЗРЕШЕНИЯ
Где тип разрешения это чтение или запись.
В результате становится достаточно просто быстро сделать ACL для папок.

#!/bin/bash
export IFS=`/bin/echo -ne "\t\n\r"`

FOLDERSLIST=`ls -A1d /pub/*/ | awk -F "/" '{ print $3 }'`

for folder in $FOLDERSLIST
do
    echo $folder
    readgroup=`getent group | grep -i atdfs | grep -i "_"$folder"_read" | grep -i read | awk -F ":" '{ print $1 }' `
    modifygroup=`getent group | grep -i atdfs | grep -i "_"$folder"_modify" | grep -i modify | awk -F ":" '{ print $1 }' `
    # echo $readgroup, $modifygroup
    setfacl -R -m g:$readgroup:rX,g:$modifygroup:rwX $folder
    getfacl --access $folder | setfacl -R -d -M- $folder

#     GROUPLIST=`getent group | grep -i "$folder" | awk -F ":" '{ print $1 }'
#     | awk '{sub(/ /,"\\ ");print}'`
#    for group in $GROUPLIST
#    do
#       echo $group
#    done

done

среда, 20 октября 2010 г.

Удаляем старые файлы из папки:

Option Explicit
Dim fso, dTwoWeeksAgo
dTwoWeeksAgo = Date() - 14
wscript.echo dTwoWeeksAgo
Set fso = CreateObject("Scripting.FileSystemObject")
'DirWalk("C:\")               ' repeat this subroutine call with a different path to process more paths
'DirWalk("F:\users\data\")   ' like this.
DirWalk("d:\pub\shared")  ' and/or like this.
Sub DirWalk(parmPath)
Dim oSubDir, oSubFolder, oFile, n
   On Error Resume Next         ' We'll handle any errors ourself, thank you very much
   Set oSubFolder = fso.getfolder(parmPath)
   For Each oFile In oSubFolder.Files   ' look in the current dir
      If Err.Number <> 0 Then   ' if we got an error, just skip this entry
         Err.Clear
      ElseIf oFile.DateLastModified < dTwoWeeksAgo Then
         'Wscript.Echo "about to delete " & oFile.Path
        '''uncomment the next line when you are satisfied this script works properly
        fso.DeleteFile oFile.Path, True
      End If
   Next
   For Each oSubDir In oSubFolder.Subfolders
      DirWalk oSubDir.Path      ' recurse the DirWalk sub with the subdir paths
   Next
   On Error Goto 0              ' Resume letting system handle errors.
End Sub

После удаляем пустые папки:
start "delete old files" /w cscript /b C:\scripts\deleteoldfiles.vbs
for /f "usebackq delims==" %%d in (`"dir d:\pub\shared /ad/b/s | sort /R"`) do rd "%%d"

Скрипт не мой ... нашел в интернете.

вторник, 31 августа 2010 г.

Установка наследования ACLов в Линуксе

Сделать это можно при помощи default ACL, применить который можно только к папке.

setfacl -R -d g:dl_sofilira_read:rX,g:dl_sofilira_modify:rwX,g:domain\ admins:rwX /var/spool/oracle/sofilira
getfacl --access /var/spool/oracle/sofilira | setfacl -d -M- /var/spool/oracle/sofilira

среда, 25 августа 2010 г.

smb.conf

# Samba config file created using SWAT
# from 192.168.1.229 (192.168.1.229)
# Date: 2009/12/09 10:49:35
[global]
workgroup = ALLIANCETRAVEL
realm = ALLIANCETRAVEL.RU
server string =
security = ADS
auth methods = winbind, sam, guest
password server = vm-dc.alliancetravel.ru
passdb backend = tdbsam
acl compatibility = win2k
load printers = No
ldap ssl = no
idmap backend = ad
idmap negative cache time = 30
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
template shell = /bin/bash
winbind enum users = Yes
winbind enum groups = Yes
winbind use default domain = Yes
winbind nss info = rfc2307
winbind refresh tickets = Yes
winbind offline logon = Yes
inherit permissions = Yes
inherit acls = Yes
cups options = raw

squid.conf

http_port 3128
# dns_nameservers 192.168.1.18
dns_defnames on
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
always_direct allow QUERY
cache_mem 128 MB
cache_dir ufs /var/spool/squid 2048 16 32
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
error_directory /etc/squid/errors
access_log /var/log/squid/access.log squid
# redirector_bypass on
# redirect_program /usr/bin/squidGuard
# redirect_children 10
# redirector_bypass on
# redirect_program /opt/rejik3/redirector /opt/rejik3/redirector.conf
# redirect_children 15
auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp
auth_param ntlm children 50
auth_param ntlm keep_alive on
auth_param basic program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-basic
auth_param basic children 15
auth_param basic realm alliancetravel.ru
auth_param basic credentialsttl 2 hour
auth_param basic casesensitive off
# auth_param basic keep_alive off
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern .               0       20%     4320

acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 4343 10000 8333 8222 15100 8081 444
acl ukrest port 2157
acl IM_ports port 5222 5223 5190 3158 1863
acl CONNECT method CONNECT

external_acl_type nt_group ttl=7200 negative_ttl=120 children=50 cache=100 grace=50 %LOGIN /usr/lib/squid/wbinfo_group.pl

#
acl local src 192.168.0.0/255.255.0.0
#
acl worktime time SMTWHFA 07:50-23:00
#
acl AuthorizedUsers proxy_auth REQUIRED
#
acl pool_1 external nt_group G_proxy_pool_1
#
acl pool_2 external nt_group G_proxy_pool_2
#
acl pool_3 external nt_group G_proxy_pool_3
# Все пользователи прокси сервера
acl all_proxy_users external nt_group G_proxy_allusers
# Доступ в интернет с разрешенным набором сайтов
acl allow_standart external nt_group G_proxy_allow_standart
# Им все можно
acl allow_all external nt_group G_proxy_allow_all
# Им можно использовать метод коннект для любых портов
acl allow_connect external nt_group G_proxy_allow_connect
# Этим пользователям запрещено всё, кроме того что находится в белом списке
acl deny_all_users external nt_group G_proxy_deny_all

# УРЛы на которые ходить запрещено
acl urls_black_list url_regex -i "/etc/squid/lists/urls_black_list.txt"
# УРЛы на которые ходить можно всем
acl urls_white_list url_regex -i "/etc/squid/lists/urls_white_list.txt"
# Хосты на которые ходить запрещено
acl dst_black_list dst "/etc/squid/lists/dst_black_list.txt"
# Хосты на которые ходить можно всем
acl dst_white_list dst "/etc/squid/lists/dst_white_list.txt"
# Хосты на которые ходить можно без авторизации
acl dst_withaout_auth dst "/etc/squid/lists/dst_without_auth.txt"
# УРЛы на которые можно ходить без авторизации
acl urls_without_auth url_regex -i "/etc/squid/lists/urls_without_auth.txt"
# Хосты с которых ходить нельзя
acl src_black_list src "/etc/squid/lists/src_black_list.txt"
# Хосты с которых можно ходить всюду
acl src_white_list src "/etc/squid/lists/src_white_list.txt"
# Хосты с которых можно ходить без авторизации
acl src_white_list_without_auth src "/etc/squid/lists/src_white_list_without_auth.txt"
# УРЛы которые не надо кешировать
acl urls_no_cache url_regex -i "/etc/squid/lists/urls_no_cache.txt"
# Файлы которые не надо загружать
acl files_blacklist urlpath_regex "/etc/squid/lists/files_blacklist.txt"

no_cache deny urls_no_cache
deny_info DENY_INFO_ALL deny_all_users
deny_info DENY_INFO_SRC_BLACK_LISTS src_black_list
deny_info DENY_INFO_FILES_BLACK_LIST files_blacklist
deny_info DENY_INFO_BLACK_LISTS urls_black_list
deny_info DENY_INFO_BLACK_LISTS dst_black_list
deny_info DENY_INFO_ALL all

http_access allow manager localhost
http_access deny manager
http_access allow CONNECT dst_withaout_auth
http_access allow CONNECT urls_without_auth
http_access allow CONNECT SSL_ports
http_access allow CONNECT IM_ports
http_access allow CONNECT ukrest
http_access allow CONNECT AuthorizedUsers allow_connect
# http_access deny CONNECT AuthorizedUsers !urls_without_auth !src_white_list_without_auth !dst_withaout_auth !SSL_ports !IM_ports !ukrest
http_access deny CONNECT
http_access allow dst_withaout_auth
http_access allow urls_without_auth
http_access allow src_white_list_without_auth
http_access allow dst_white_list
http_access allow urls_white_list
http_access allow AuthorizedUsers allow_all
http_access allow AuthorizedUsers allow_standart !dst_black_list !urls_black_list !src_black_list !files_blacklist !deny_all_users
http_reply_access allow all
icp_access allow all
http_access allow all
# http_access deny all

coredump_dir /var/spool/squid
maximum_object_size 512 MB

четверг, 10 декабря 2009 г.

Репозиторий с собранной бакулой для CentOS

[pp-contrib]
name=PPs packages for Red Hat Enterprise Linux 5 - contrib
baseurl=ftp://ftp.pramberger.at/systems/linux/contrib/rhel5/$basearch/
gpgcheck=1
gpgkey=ftp://ftp.pramberger.at/systems/linux/contrib/rhel5/RPM-GPG-KEY-6971f6ac
enabled=1
priority=30

[pp-contrib-debug]
name=PPs packages for Red Hat Enterprise Linux 5 - debug
baseurl=ftp://ftp.pramberger.at/systems/linux/contrib/rhel5/$basearch/debug/
gpgcheck=1
gpgkey=ftp://ftp.pramberger.at/systems/linux/contrib/rhel5/RPM-GPG-KEY-6971f6ac
enabled=0
priority=30

[pp-contrib-source]
name=PPs packages for Red Hat Enterprise Linux 5 - source
baseurl=ftp://ftp.pramberger.at/systems/linux/contrib/rhel5/SRPMS/
gpgcheck=1
gpgkey=ftp://ftp.pramberger.at/systems/linux/contrib/rhel5/RPM-GPG-KEY-6971f6ac
enabled=0
priority=30

Bacula, шаблон для вставки в конфиг стораж демона

Device {
 Name = @compname@-FileStorage
 Device Type = File
 Media Type = @compname@-File
 Archive Device = /bacula/devices/@compname@
 Random Access = Yes
 AutomaticMount = yes
 RemovableMedia = no
 AlwaysOpen = no
 LabelMedia = yes
}

Bacula, шаблон для вставки в конфиг директора

# @compname@ dir
# Client (File Services) to backup
Job {
 Name = "@compname@-job"
 JobDefs = "DefaultJob2"
 Write Bootstrap = "/var/lib/bacula/@compname@.bsr"
 Client = @compname@-fd
 FileSet = "@compname@-FileSet"
 Storage = "@compname@-FileStorage"
 ClientRunBeforeJob = "\"E:/Documents and Settings/All Users/Application Data/Bacula/runbefore.bat\""
 ClientRunAfterJob = "\"E:/Documents and Settings/All Users/Application Data/Bacula/runafter.bat\""
}

Client {
 Name = @compname@-fd
 Maximum Concurrent Jobs = 20
 Address = @compname@.local
 FDPort = 9102
 Catalog = MyCatalog
 Password = "passworrd"          # password for FileDaemon
 File Retention = 60 days            # 30 days
 Job Retention = 6 months            # six months
 AutoPrune = yes                     # Prune expired Jobs/Files
}

# List of files to be backed up
FileSet {
 Name = "@compname@-FileSet"
 Enable VSS = yes
 Include {
   Options {
     signature = MD5
     compression = GZIP
     IgnoreCase = yes
     Exclude = yes
     WildDir = "[A-Z]:/temp"
     WildFile = "*.tmp"
     WildDir = "[A-Z]:/RECYCLER"
     WildFile = "[A-Z]:/pagefile.sys"
     WildFile = "[A-Z]:/Documents and Settings/*/LocalSettings/Application Data/Microsoft/Windows/usrclass.*"
     WildFile = "[A-Z]:/Documents and Settings/*/ntuser.*"
     WildDir = "[A-Z]:/Documents and Settings/*/Cookies"
     WildDir = "[A-Z]:/Documents and Settings/*/Recent"
     WildDir = "[A-Z]:/Documents and Settings/*/LocalSettings/History"
     WildDir = "[A-Z]:/Documents and Settings/*/LocalSettings/Temp"
     WildDir = "[A-Z]:/Documents and Settings/*/LocalSettings/Temporary Internet Files"
     # These are always open and unable to be backed up
     WildFile = "[A-Z]:/Documents and Settings/All Users/ApplicationData/Microsoft/Network/Downloader/qmgr[01].dat"
     WildFile = "*.mp1"
     WildFile = "*.mp2"
     WildFile = "*.mp3"
     WildFile = "*.avi"
     WildFile = "*.mpg"
     WildFile = "*.mpeg"
     WildFile = "*.ogg"
   }
   File = C:/SystemStateBackup.bkf
   File = E:/

 }
 Exclude {
 }
}

# Definition of file storage device
Storage {
 Name = @compname@-FileStorage
 Maximum Concurrent Jobs = 1
 Address = at0038.local                # N.B. Use a fully qualified name here
 SDPort = 9103
 Password = "passworrd"
 Device = @compname@-FileStorage
 Media Type = @compname@-File
}

Bacula, конфиг файд демона

Director {
 Name = at0038-dir
 Password = "passworrd"
}

Director {
 Name = at0038-mon
 Password = "passworrd"
 Monitor = yes
}

FileDaemon {                          # this is me
 Name = at0038-fd
 FDport = 9102                  # where we listen for the director
 WorkingDirectory = /var/lib/bacula
 Pid Directory = /var/run
 Maximum Concurrent Jobs = 100
}

Messages {
 Name = Standard
 director = at0038-dir = all, !skipped, !restored
}

Bacula, конфиг стораждемона

Storage {                             # definition of myself
 Name = at0038-sd
 SDPort = 9103
 WorkingDirectory = "/var/lib/bacula"
 Pid Directory = "/var/run"
 Maximum Concurrent Jobs = 20
}

Director {
 Name = at0038-dir
 Password = "passworrd"
}

Director {
 Name = at0038-mon
 Password = "passworrd"
 Monitor = yes
}

Device {
 Name = FileStorage
 Media Type = File
 Archive Device = /bacula/devices/default
 LabelMedia = yes
 Random Access = Yes
 AutomaticMount = yes
 RemovableMedia = no
 AlwaysOpen = no
}

Messages {
 Name = Standard
 director = at0038-dir = all
}

@/etc/bacula/conf.d/at0036-sd.conf
@/etc/bacula/conf.d/at0038-sd.conf
@/etc/bacula/conf.d/at0089-sd.conf
@/etc/bacula/conf.d/at-inf-sd.conf
@/etc/bacula/conf.d/at-main-sd.conf
@/etc/bacula/conf.d/at-tkp-sd.conf
@/etc/bacula/conf.d/at-stack1-sd.conf
@/etc/bacula/conf.d/atrec-sd.conf
@/etc/bacula/conf.d/vm-av-sd.conf
@/etc/bacula/conf.d/vm-bc-sd.conf
@/etc/bacula/conf.d/vm-dc-sd.conf
@/etc/bacula/conf.d/vm-fs-sd.conf
@/etc/bacula/conf.d/vm-ftp-sd.conf
@/etc/bacula/conf.d/vm-netpromoter-sd.conf
@/etc/bacula/conf.d/vm-netxms-sd.conf
@/etc/bacula/conf.d/vm-ns1-sd.conf
@/etc/bacula/conf.d/vm-ora-sd.conf
@/etc/bacula/conf.d/vm-proxy-sd.conf
@/etc/bacula/conf.d/vm-ras-sd.conf
@/etc/bacula/conf.d/vm-rt-sd.conf
@/etc/bacula/conf.d/vm-site-sd.conf
@/etc/bacula/conf.d/vm-smtp-sd.conf
@/etc/bacula/conf.d/vm-syslog-sd.conf
@/etc/bacula/conf.d/vm-ts-sd.conf
@/etc/bacula/conf.d/vm-ts2-sd.conf
@/etc/bacula/conf.d/vm-wsus-sd.conf
@/etc/bacula/conf.d/vm-www4-sd.conf
@/etc/bacula/conf.d/vm-www5-sd.conf

Bacula, конфиг директора

Director {
 Name = at0038-dir
 DIRport = 9101
 QueryFile = "/etc/bacula/scripts/query.sql"
 WorkingDirectory = "/var/lib/bacula"
 PidDirectory = "/var/run"
 Maximum Concurrent Jobs = 20
 Password = "passworrd"
 Messages = Daemon
}

Console {
 Name = at0038-mon
 Password = "passworrd"
 CommandACL = status, .status
}

# Generic catalog service
Catalog {
 Name = MyCatalog
 dbname = "bacula"; dbuser = "bacula"; dbpassword = "passworrd"
}

JobDefs {
 Name = "DefaultJob"
 Maximum Concurrent Jobs = 20
 Type = Backup
 Level = Incremental
 Schedule = "WeeklyCycle"
 Messages = Standard
 Pool = Default
 Priority = 10
}

JobDefs {
 Name = "DefaultJob2"
 Maximum Concurrent Jobs = 20
 Type = Backup
 Level = Incremental
 Schedule = "WeeklyCycle2"
 Messages = Standard
 Pool = inc-pool
 Priority = 10
}

JobDefs {
 Name = "DefaultJob3"
 Maximum Concurrent Jobs = 20
 Type = Backup
 Level = Incremental
 Schedule = "WeeklyCycle3"
 Messages = Standard
 Pool = inc-pool
 Priority = 10
}

Job {
 Name = "RestoreFiles"
 Type = Restore
 Client= at0038-fd
 FileSet="at0038-FileSet"
 Storage = FileStorage
 Pool = Default
 Messages = Standard
 Where = /bacula/restores
 Priority = 11
 Maximum Concurrent Jobs = 20
}

Schedule {
 Name = "WeeklyCycle"
 Run = FullPool=fullbackup-pool Level=Full Pool=fullbackup-pool 1st fri at 23:05
 Run = DifferentialPool=diffbackup-pool Level=Differential Pool=diffbackup-pool 2nd-5th fri at 23:05
 Run = IncrementalPool=incbackup-pool Level=Incremental Pool=incbackup-pool sat,sun,mon,tue,wed,thu at 23:05
}

Schedule {
 Name = "WeeklyCycle2"
 Run = FullPool=full-pool Level=Full Pool=full-pool 1st fri at 23:05
 Run = DifferentialPool=diff-pool Level=Differential Pool=diff-pool 2nd-5th fri at 23:05
 Run = IncrementalPool=inc-pool Level=Incremental Pool=inc-pool sat,sun,mon,tue,wed,thu at 23:05
}

Schedule {
 Name = "WeeklyCycle3"
 Run = FullPool=full-pool Level=Full Pool=full-pool 1st fri at 21:05
 Run = DifferentialPool=diff-pool Level=Differential Pool=diff-pool 2nd-5th fri at 21:05
 Run = IncrementalPool=inc-pool Level=Incremental Pool=inc-pool sat,sun,mon,tue,wed,thu at 21:05
}

Schedule {
 Name = "WeeklyCycleAfterBackup"
 Run = Full sun-sat at 23:10
}

Storage {
 Name = FileStorage
 Maximum Concurrent Jobs = 1
 Address = at0038.local
 SDPort = 9103
 Password = "passworrd"
 Device = FileStorage
 Media Type = File
}

Messages {
 Name = Standard
 operatorcommand = "/usr/bin/bsmtp -h localhost -f bacula@at0038.local -s \"Bacula: Intervention needed for %j\" %r"
 mailcommand = "/usr/bin/bsmtp -8 -h localhost -f bacula@at0038.local -r it@mydomain.local -s \"%c %n %l %t: %e\" %r"
 mail = logwatch@mydomain.local = all, !skipped
 operator = logwatch@mydomain.local = mount
 console = all, !skipped, !saved
 append = "/var/log/bacula/bacula.log" = all, !skipped
}

Messages {
 Name = Daemon
 mailcommand = "/usr/bin/bsmtp -h localhost -f bacula@at0038.local -s \"Bacula daemon message\" %r"
 mail = logwatch@mydomain.local = all, !skipped
 console = all, !skipped, !saved
 append = "/var/log/bacula/bacula.log" = all, !skipped
}

Pool {
 Name = Default
 Pool Type = Backup
 Recycle = yes                       # Bacula can automatically recycle Volumes
 AutoPrune = yes                     # Prune expired volumes
 Volume Retention = 365 days         # one year
 Label Format = "default-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}"
}

Pool {
 Name = Scratch
 Pool Type = Backup
}

Pool {
   Name = fullbackup-pool
   Pool Type = Backup
   Volume Retention = 200 days
   AutoPrune = yes
   Label Format = "fullbackup-${Job}-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}${Second:p/2/0/r}"
   Use Volume Once = Yes
}

Pool {
   Name = diffbackup-pool
   Pool Type = Backup
   Volume Retention = 28 days
   AutoPrune = yes
   Label Format = "diffbackup-${Job}-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}${Second:p/2/0/r}"
}

Pool {
   Name = incbackup-pool
   Pool Type = Backup
   Volume Use Duration = 6 days
   Volume Retention = 7 days
   AutoPrune = yes
   Label Format = "incbackup-${Job}-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}${Second:p/2/0/r}"
}

Pool {
   Name = full-pool
   Pool Type = Backup
   Volume Retention = 200 days
   AutoPrune = yes
   Label Format = "${Job}-full-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}${Second:p/2/0/r}"
   Use Volume Once = Yes
}

Pool {
   Name = diff-pool
   Pool Type = Backup
   Volume Retention = 28 days
   AutoPrune = yes
   Label Format = "${Job}-diff-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}${Second:p/2/0/r}"
   Use Volume Once = Yes
}

Pool {
   Name = inc-pool
   Pool Type = Backup
   Volume Use Duration = 6 days
   Volume Retention = 7 days
   AutoPrune = yes
   Label Format = "${Job}-inc-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}${Second:p/2/0/r}"
   Use Volume Once = Yes
}

@/etc/bacula/conf.d/at0036-dir.conf
@/etc/bacula/conf.d/at0038-dir.conf
@/etc/bacula/conf.d/at0089-dir.conf
@/etc/bacula/conf.d/at-inf-dir.conf
@/etc/bacula/conf.d/at-main-dir.conf
@/etc/bacula/conf.d/atrec-dir.conf
@/etc/bacula/conf.d/at-stack1-dir.conf
# @/etc/bacula/conf.d/at-tkp-dir.conf
@/etc/bacula/conf.d/vm-av-dir.conf
@/etc/bacula/conf.d/vm-bc-dir.conf
@/etc/bacula/conf.d/vm-dc-dir.conf
@/etc/bacula/conf.d/vm-fs-dir.conf
@/etc/bacula/conf.d/vm-ftp-dir.conf
# @/etc/bacula/conf.d/vm-netpromoter-dir.conf
# @/etc/bacula/conf.d/vm-netxms-dir.conf
@/etc/bacula/conf.d/vm-ns1-dir.conf
@/etc/bacula/conf.d/vm-ora-dir.conf
@/etc/bacula/conf.d/vm-proxy-dir.conf
@/etc/bacula/conf.d/vm-ras-dir.conf
@/etc/bacula/conf.d/vm-rt-dir.conf
@/etc/bacula/conf.d/vm-site-dir.conf
@/etc/bacula/conf.d/vm-smtp-dir.conf
@/etc/bacula/conf.d/vm-syslog-dir.conf
@/etc/bacula/conf.d/vm-ts-dir.conf
@/etc/bacula/conf.d/vm-ts2-dir.conf
@/etc/bacula/conf.d/vm-wsus-dir.conf
@/etc/bacula/conf.d/vm-www4-dir.conf
@/etc/bacula/conf.d/vm-www5-dir.conf

четверг, 8 октября 2009 г.

Удаляем старые резервные копии

Смысл: Скопились файлы с резервными копиями, информация о которых отсутсвует в каталоге Baculы. Надо бы от них избавиться.
Что делать? Надо узнать если информация в каталоге бакулы по каждому файлу в папках устройств.
Скрипт:
#!/bin/bash
devicesdir=/bacula/devices
medianame=''
result=''
mysql_host="localhost"
mysql_db="bacula"
mysql_user="bacula"
mysql_password=""

for myfile in $devicesdir/*/*
do
medianame=`echo "$myfile" | cut -d'/' -f5`
result=`echo "select VolumeName FROM Media WHERE VolumeName=\"$medianame\";" | mysql -h $mysql_host -u $mysql_user -p$mysql_password $mysql_db`
if [ "$result" = "" ]
then
rm -fv $myfile
fi
done

В итоге скрипт удалит все файлы, информация о которых не нашлась в каталоге.

Использовать крайне осторожно! Можно лишиться своих резервных копий.

вторник, 21 июля 2009 г.

Автомобильная аптечка

1. Обезболивающие, противовоспалительные и противо шоковые средства при травме (ушибы, переломы, вывихи), ранениях, шоке.
1.1. Анальгин 0,5 № 10 (или аналог) 1 уп.
аспирин 0,5 № 10 1 уп.
1.2. Портативный гипотермический (охлаждающий) пакет-контейнер 1 шт.
1.3. Раствор сульфацила натрия 1 фл.

2. Средства для остановки кровотечения, обработки и перевязки ран.
2.1. Жгут для остановки артериального кровотечения с дозированной компрессией (сдавливанием) для само- и взаимопомощи 1 шт.
2.2. Бинт стерильный 10Ч5 1 шт.
2.3. Бинт нестерильный 10Ч5 1 шт.
2.4. Бинт нестерильный 5Ч5 1 шт.
2.5. Атравматическая повязка МАГ с диоксидином или нитратом серебра 8Ч10 для перевязки грязных ран 1 шт.
2.6. Лейкопластырь бактерицидный 2,5Ч7,2 или 2Ч5 8 шт.
2.7. Салфетки стерильные для остановки капиллярного и венозного кровотечения «Колетекс ГЕМ» с фурагином 6Ч10 см, 10Ч18 см 3 шт. или Статин (порошок) 1,0 гр 3 уп.
2.8. Раствор йода спиртовой 5% или бриллиантовой зелени 1% 1 фл.
2.9. Лейкопластырь 1Ч500 или 2Ч500 или 1Ч250 1 шт.
2.10. Бинт эластичный трубчатый медицинский нестерильный № 1, 3, 6 по 1 шт
2.11. Вата 50 г 1 шт.

3. Средства при болях в сердце.
3.1. Нитроглицерин таб. № 40 или капс. № 20 (тринитролонг) 1 уп.
3.2. Валидол таб. или капс. 1 уп.

4. Средства для сердечно-легочной реанимации при клинической смерти.
4.1. Устройство для проведения искусственного дыхания «Рот-в-рот» 1 шт.

5. Средство при обмороке (коллапсе).
5.1. Аммиака раствор (нашатырный спирт) 1 фл.

6. Средство для дезинтоксикации при отравлениях пищей и т.д.
6.1. Энтеродеа 2 уп.
или уголь активированный в табл. № 10 1 уп.

7. Средство при стрессовых реакциях.
7.1. Корвалол 1 фл.

8. Ножницы тупоконечные 1 шт.

9. Инструкция

10. Футляр пластмассовый

понедельник, 6 апреля 2009 г.

Правим UDEV для DV камеры

В файле /lib/udev/rules.d/50-udev-default.rules

Правим:
# KERNEL=="dv1394[0-9]*", NAME="dv1394/%n", GROUP="video"
KERNEL=="video1394[0-9]*", NAME="video1394/%n", GROUP="video"
KERNEL=="dv1394*", GROUP="video"
KERNEL=="raw1394", GROUP="plugdev"

среда, 1 апреля 2009 г.

Установка bacula

Журнал, backup сервер, установка и настройка
hostname нашего сервера: at0038

У меня контроллер на 8 дисков, по 500 гБ каждый
Делаем два RAID массива, system - 60 GB, data - 2700 GB
Это необходимо, из-за того, что CentOS не может установиться на раздел больше чем 2 ТБ.
sda1 - 10 gb / (корневой раздел оставляем не на ЛВМ)
sda2 - 50 gb pv
sdb1 - 2,6 tb pv
vg0 - /dev/sda2 (Один волумгруп для системных разделов)
vg1 - /dev/sdb1 (один волум групп для данных)
vg0/lv_swap - 2 gb - swap
vg0/lv_var - 10 gb - /var
vg0/lv_tmp - 10 gb - /tmp
vg0/lv_usr - 10 gb - /usr
vg1/lv_bacula - 2,6 tb - /bacula

Centos 5.2 - Установка поумолчанию.
Обновляемся после установки.

Качаем свежую сборку bacula rpms-contrib-fschwarz
Устанавливаем:
качаем ключ: wget http://freefr.dl.sourceforge.net/sourceforge/bacula/fschwarz.asc
устанавливаем ключ: rpm --import fschwarz.asc
yum --nogpgcheck install bacula-mysql-2.4.2-1.el5.i386.rpm bacula-bat-2.4.2-1.el5.i386.rpm bacula-gconsole-2.4.2-1.el5.i386.rpm
правим /etc/aliases:
root: тут адрес на который должны приходить инормационные письма
# newaliases
# /etc/init.d/sendmail restart
Настройка Bacula

Читать:
http://www.opennet.ru/soft/Short_Doc_Bacula.pdf
http://santa-claus-rpm.livejournal.com/5066.html
http://www.opennet.ru/soft/Bacula_PDC_backup.pdf
http://wiki.bacula.org/doku.php
http://www.bog.pp.ru/work/bacula.html

В папке /bacula/devices - создаю папки для каждого клиента, каждая папка устройство (device), бакула не может писать два задания на одно устройство одновременно, если хотим чтобы копирование происходило с нескольких клиентов одновременно, тогда нужно создать несколько устройств.

Конфигурационные файлы:

bacula-dir.conf:

Director {
Name = at0038-dir
DIRport = 9101
QueryFile = "/usr/lib/bacula/query.sql"
WorkingDirectory = "/var/lib/bacula"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 10
Password = "12345"
Messages = Daemon
}

Console {
Name = at0038-mon
Password = "12345"
CommandACL = status, .status
}

# Generic catalog service
Catalog {
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = ""
}

JobDefs {
Name = "DefaultJob"
Maximum Concurrent Jobs = 20
Type = Backup
Level = Incremental
Schedule = "WeeklyCycle"
Messages = Standard
Pool = Default
Priority = 10

}

Job {
Name = "RestoreFiles"
Type = Restore
Client= at0038-fd
FileSet="at0038-FileSet"
Storage = FileStorage
Pool = Default
Messages = Standard
Where = /bacula/restores
Priority = 11
Maximum Concurrent Jobs = 100
}

Schedule {
Name = "WeeklyCycle"
Run = FullPool=fullbackup-pool Level=Full Pool=fullbackup-pool 1st fri at 23:05
Run = DifferentialPool=diffbackup-pool Level=Differential Pool=diffbackup-pool 2nd-5th fri at 23:05
Run = IncrementalPool=incbackup-pool Level=Incremental Pool=incbackup-pool sat,sun,mon,tue,wed,thu at 23:05
}

Schedule {
Name = "WeeklyCycleAfterBackup"
Run = Full sun-sat at 23:10
}

Storage {
Name = FileStorage
Maximum Concurrent Jobs = 1
Address = at0038
SDPort = 9103
Password = "12345"
Device = FileStorage
Media Type = File
}


Messages {
Name = Standard
operatorcommand = "/usr/sbin/bsmtp -h localhost -f bacula@at0038 -s \"Bacula: Intervention needed for %j\" %r"
mailcommand = "/usr/sbin/bsmtp -8 -h localhost -f bacula@at0038 -s \"%c %n %l %t: %e\" %r"
mail = root@localhost = all, !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
append = "/var/lib/bacula/log" = all, !skipped
}

Messages {
Name = Daemon
mailcommand = "/usr/sbin/bsmtp -h localhost -f bacula@at0038 -s \"Bacula daemon message\" %r"
mail = root@localhost = all, !skipped
console = all, !skipped, !saved
append = "/var/lib/bacula/log" = all, !skipped
}

Pool {
Name = Default
Pool Type = Backup
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
Label Format = "default-${Job}-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}"
}

Pool {
Name = Scratch
Pool Type = Backup
}

Pool {
Name = fullbackup-pool
Pool Type = Backup
Volume Retention = 200 days
AutoPrune = yes
RecyclePool = Scratch
Recycle = yes
Recycle Oldest Volume = yes
Label Format = "fullbackup-${Job}-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}${Second:p/2/0/r}"
Use Volume Once = Yes
}

Pool {
Name = diffbackup-pool
Pool Type = Backup
Volume Retention = 40 days
AutoPrune = yes
RecyclePool = Scratch
Recycle = yes
Recycle Oldest Volume = yes
Label Format = "diffbackup-${Job}-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}${Second:p/2/0/r}"
Use Volume Once = Yes
}

Pool {
Name = incbackup-pool
Pool Type = Backup
Volume Use Duration = 7 days
Volume Retention = 8 days
AutoPrune = yes
RecyclePool = Scratch
Recycle = yes
Recycle Oldest Volume = yes
Label Format = "incbackup-${Job}-${Year}${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}${Minute:p/2/0/r}${Second:p/2/0/r}"
Use Volume Once = Yes
}

@/etc/bacula/conf.d/шаблон для каждого клиента компьютера (имякомпьютера-dir.conf)

bacula-sd.conf:

Storage { # definition of myself
Name = at0038-sd
SDPort = 9103
WorkingDirectory = "/var/lib/bacula"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}

Director {
Name = at0038-dir
Password = "12345"
}

Director {
Name = at0038-mon
Password = "12345"
Monitor = yes
}

Device {
Name = FileStorage
Media Type = File
Archive Device = /bacula/devices/default
LabelMedia = yes
Random Access = Yes
AutomaticMount = yes
RemovableMedia = no
AlwaysOpen = no
}

Messages {
Name = Standard
director = at0038-dir = all
}

@/etc/bacula/conf.d/шаблон для каждого клиента компьютера (имякомпьютера-sd.conf)

bacula-fd.conf:

Director {
Name = at0038-dir
Password = "12345"
}

Director {
Name = at0038-mon
Password = "12345"
Monitor = yes
}

FileDaemon { # this is me
Name = at0038-fd
FDport = 9102 # where we listen for the director
# WorkingDirectory = "C:\\Documents and Settings\\All Users\\Application Data\\Bacula\\Work"
# Pid Directory = "C:\\Documents and Settings\\All Users\\Application Data\\Bacula\\Work"
WorkingDirectory = /var/lib/bacula
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
}

Messages {
Name = Standard
director = at0038-dir = all, !skipped, !restored
}

bat.conf, bconsole.conf

Director {
Name = at0038-dir
DIRport = 9101
address = at0038
Password = "12345"
}

шаблон-dir.conf:

# %wintemplate% dir
# Client (File Services) to backup
Job {
Name = "%wintemplate%-job"
Maximum Concurrent Jobs = 10
JobDefs = "DefaultJob"
Write Bootstrap = "/var/lib/bacula/%wintemplate%.bsr"
Client = %wintemplate%-fd
FileSet = "%wintemplate%-FileSet"
Storage = "%wintemplate%-FileStorage"
ClientRunBeforeJob = "\"C:\\Documents and Settings\\All Users\\Application Data\\Bacula\\runbefore.bat\""
ClientRunAfterJob = "\"C:\\Documents and Settings\\All Users\\Application Data\\Bacula\\runafter.bat\""
}

Client {
Name = %wintemplate%-fd
Maximum Concurrent Jobs = 10
Address = %wintemplate%
FDPort = 9102
Catalog = MyCatalog
Password = "12345" # password for FileDaemon
File Retention = 60 days # 30 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}

# List of files to be backed up
FileSet {
Name = "%wintemplate%-FileSet"
Enable VSS = yes
Include {
Options {
signature = MD5
compression = GZIP
IgnoreCase = yes
Exclude = yes
WildDir = "[A-Z]:/temp"
WildFile = "*.tmp"
WildDir = "[A-Z]:/RECYCLER"
WildFile = "[A-Z]:/pagefile.sys"
WildFile = "*.mp1"
WildFile = "*.mp2"
WildFile = "*.mp3"
WildFile = "*.avi"
WildFile = "*.mpg"
WildFile = "*.mpeg"
WildFile = "*.ogg"
WildFile = "*.cdx"
}
File = C:/SystemStateBackup.bkf
}
Exclude {
}
}

# Definition of file storage device
Storage {
Name = %wintemplate%-FileStorage
Maximum Concurrent Jobs = 10
Address = at0038
SDPort = 9103
Password = "12345"
Device = %wintemplate%-FileStorage
Media Type = %wintemplate%-File
}

шаблон-dir.conf (linux):

# %nixtemplate% dir
# Client (File Services) to backup
Job {
Name = "%nixtmplate%-job"
Maximum Concurrent Jobs = 10
JobDefs = "DefaultJob"
Write Bootstrap = "/var/lib/bacula/at0038.bsr"
Client = at0038-fd
FileSet = "%nixtmplate%-FileSet"
Storage = %nixtmplate%-FileStorage
}

Client {
Name = %nixtmplate%-fd
Maximum Concurrent Jobs = 10
Address = %nixtmplate%
FDPort = 9102
Catalog = MyCatalog
Password = "12345" # password for FileDaemon
File Retention = 60 days # 30 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}

# List of files to be backed up
FileSet {
Name = "%nixtmplate%-FileSet"
Include {
Options {
signature = MD5
compression = GZIP
}
File = /home
File = /etc
File = /usr/local
File = /opt
File = /root
File = /var/log
File = /var/run
File = /var/spool
}

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

# Definition of file storage device
Storage {
Name = %nixtmplate%-FileStorage
Maximum Concurrent Jobs = 10
Address = at0038
SDPort = 9103
Password = "12345"
Device = %nixtmplate%-FileStorage
Media Type = %nixtmplate%-File
}

шаблон-sd:

Device {
Name = %template%-FileStorage
Device Type = File
Media Type = %template%-File
Archive Device = /bacula/devices/%template%
Random Access = Yes
AutomaticMount = yes
RemovableMedia = no
AlwaysOpen = no
LabelMedia = yes
}