Koozali.org: home of the SME Server

Add cronjob ?

Offline fpausp

  • *
  • 728
  • +0/-0
Add cronjob ?
« on: July 11, 2006, 09:28:35 PM »
Hallo All,

I have installed the sme-crontab_manager-1.2-1.noarch.rpm and it works very well for me.

Now i like to customize every new server with a script (backupscript etc ...)

Is it possibe to add a cronjob with a shellscript, that job should be visable in the crontab_manager, how could that script looks like ?


fpausp
Viribus unitis

Offline MasterSleepy

  • *
  • 386
  • +0/-0
    • http://www.vanhees.cc
Add cronjob ?
« Reply #1 on: July 12, 2006, 10:09:26 AM »
Hello,

If it is the first task you want to add try
Code: [Select]
db configuration setprop cronmanager task1 28,NO,1,NO,1,NO,*,*,root,backupscript
expand-template /etc/crontab

this will execute you script each first day of month at 1:28.

Regards.

Offline fpausp

  • *
  • 728
  • +0/-0
Add cronjob ?
« Reply #2 on: July 13, 2006, 07:29:03 PM »
Thanks a lot,

db configuration setprop cronmanager task1 15,NO,23,NO,*,,*,*,root,/home/backup/scripts/ldap_backup.sh
db configuration setprop cronmanager task2 30,NO,23,NO,*,,*,*,root,/home/backup/scripts/mysql_backup.sh
db configuration setprop cronmanager task3 45,NO,23,NO,*,,*,*,root,/home/backup/scripts/pgsql_backup.sh
db configuration setprop cronmanager task4 0,NO,0,NO,*,,*,*,root,/home/backup/scripts/tarbackup.sh
expand-template /etc/crontab


that works great.

regards fpausp
Viribus unitis

Offline lucho115

  • *****
  • 209
  • +0/-0
    • http://www.elac.com.ar
Add cronjob ?
« Reply #3 on: July 19, 2006, 05:51:28 PM »
can you post yours scripts to backup ldap, mysql,. etcc..., its will be very important to me , because iam learning to doit shell scripts and i want to see some well doit.
thanks
bye

Offline fpausp

  • *
  • 728
  • +0/-0
Add cronjob ?
« Reply #4 on: July 19, 2006, 08:36:52 PM »
OK thats the scripts i use at the moment, i have not completed my work and i am also searching for scripts better than mine, use it at your own risk !!!: :idea:


LDAP:------------------------------------------------------------------------------

#!/bin/bash
 
######
# ldap_dump.sh
#  - create an LDAP dump and save it into a "secure" directory
#
# Autor: Frank Proessdorf
######
 
PFAD=/home/backup/ldap
DATE=date +%d%m%y
DUMPFILE=ldapdb_$DATE.ldif

# create secure folder if it doesn't exist
if [ ! -d $PFAD ]
then
        echo "Sicherer Pfad wird angelegt.."
        mkdir $PFAD
        chmod 700 $PFAD
fi

cd $PFAD

# dump LDAP
slapcat -l $DUMPFILE

# gzip the dump
gzip $DUMPFILE

# set correct mode
chmod 600 $DUMPFILE.gz

# finden und löschen von dateien die älter sind als x (-mtime +14) Tage

find /home/backup/ldap  -iname 'ldapdb_*.ldif.gz' -mtime +14 | xargs --no-run-if-empty rm -f


#####
# The LDIF generated by this tool is suitable for use with slapadd(8).  
# As the entries are in database order, not superior first order,  they  cannot
# be loaded with ldapadd(1) without first being reordered.
#####



MYSQL:------------------------------------------------------------------------------

#!/bin/bash

###### mysql backup-script #####

# Verzeichnis anlegen
mkdir /home/backup/mysql/mysql_date '+%d%m%y'

# Datenbank dumpen
mysqldump -u root -h localhost -A > /home/backup/mysql/mysql_date '+%d%m%y'/mysqldb_date '+%d%m%y_%H%M'.sql

# Gzippen
gzip -f /home/backup/mysql/mysql_date '+%d%m%y*'/*.sql

# Finden von Datein/Verzeichnisen die älter als x Tage sind und löschen
find /home/backup/mysql/mysql* -iname 'mysqldb*.sql.gz' -mtime +14 | xargs --no-run-if-empty rm -f

# Finden von Datein/Verzeichnisen die älter als x Tage sind und löschen
find /home/backup/mysql -iname 'mysql*' -mtime +14 | xargs rm -f -r




PGSQL:------------------------------------------------------------------------------

#!/bin/bash

##### pgsql backup-script #####

# Verzeichnis anlegen
mkdir /home/backup/pgsql/lxoffice_date '+%d%m%y'
mkdir /home/backup/pgsql/openexchange_date '+%d%m%y'
mkdir /home/backup/pgsql/template1_date '+%d%m%y'

# Datenbank dumpen
pg_dump -U postgres lxoffice > /home/backup/pgsql/lxoffice_date '+%d%m%y'/lxofficedb_date '+%d%m%y_%H%M'.sql
pg_dump -U postgres openexchange > /home/backup/pgsql/openexchange_date '+%d%m%y'/openexchangedb_date '+%d%m%y_%H%M'.sql
pg_dump -U postgres template1 > /home/backup/pgsql/template1_date '+%d%m%y'/template1db_date '+%d%m%y_%H%M'.sql

# Gzippen
gzip -f /home/backup/pgsql/lxoffice_date '+%d%m%y*'/*.sql
gzip -f /home/backup/pgsql/openexchange_date '+%d%m%y*'/*.sql
gzip -f /home/backup/pgsql/template1_date '+%d%m%y*'/*.sql

# Finden von Datein/Verzeichnisen die älter als x Tage sind und löschen
find /home/backup/pgsql/lxoffice* -iname 'lxoffice_*.sql.gz' -mtime +14 | xargs --no-run-if-empty rm -f
find /home/backup/pgsql/openexchange* -iname 'openexchange_*.sql.gz' -mtime +14 | xargs --no-run-if-empty rm -f
find /home/backup/pgsql/template1* -iname 'template1_*.sql.gz' -mtime +14 | xargs --no-run-if-empty rm -f

# Finden von Datein/Verzeichnisen die älter als x Tage sind und löschen
find /home/backup/pgsql -iname 'pgsql*' -mtime +14 | xargs rm -f -r


regards
fpausp
Viribus unitis