Zalohovanie

Juraj Chlebec Juraj.Chlebec at fem.uniag.sk
Wed Jun 1 12:17:51 CEST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Novak wrote:
> Dakujem, ano tak som to planoval. Ale potrebujem nato napisat skript ktory sa bude pravidelne spustat. Priklad: zataruje adresar, ktory nasledne ulozi ako subor s datumom (1_6_2005.tar) a napali. Problem je v tom, ze ten skript neviem napisat :-)
> Dakujem
> 

Spusta sa v adresari do ktoreho sa ma vykonat backup - uprava by mala
byt jednoducha...

WORK_DIR je adresar z ktoreho sa ma nieco zalohovat
PACK_DIR je meno adresara ktory sa bude zalohovat (WORK_DIR+PACK_DIR je
         cesta k adresaru ktory sa zalohuje)
BASENAME je meno suboru do ktoreho sa bude balit
DB_NAME  je meno databazy s ktorej sa bude robit dump

Ostatne je snad jasne... v tomto pripade je databaza PostgreSQL
To napalovanie si treba dopisat s tym zasa nemam ja ziadne skusenosti :)

Juro Chlebec



#!/bin/sh
WORK_DIR=/data/www/htdocs.ex
PACK_DIR=moodle

BASENAME=moodle
DBNAME=ex_moodle

PGUSER=ex_moodle
PGPASSWORD=**********
PGHOST=fem2
export PGUSER PGPASSWORD PGHOST

CURRENT_DIR=`pwd`
CURRENT_DATE=`date "+%Y%m%d%H%M"`
SQL_DUMP_NAME=$BASENAME-$CURRENT_DATE.sql
PACK_FILE_NAME=$BASENAME-$CURRENT_DATE.tar

echo '*** Dumping database '$DBNAME
pg_dump -i -d $DBNAME > $CURRENT_DIR/$SQL_DUMP_NAME
cd $WORK_DIR
echo '*** Taring directory '$PACK_DIR' in to file '$PACK_FILE_NAME
tar -cf $CURRENT_DIR/$PACK_FILE_NAME $PACK_DIR
cd $CURRENT_DIR
echo '*** Taring '$SQL_DUMP_NAME' in to '$PACK_FILE_NAME
tar -rf $CURRENT_DIR/$PACK_FILE_NAME $SQL_DUMP_NAME
echo '*** Removing '$SQL_DUMP_NAME
rm -f $SQL_DUMP_NAME
echo '*** Gziping '$PACK_FILE_NAME
gzip -f9 $PACK_FILE_NAME
echo '*** Backup END'



- --
Bc. Juraj Chlebec aka Havran
http://www.fem.uniag.sk/havran - Havranov mini-blog
http://belit.bloguje.cz - BELIT-blog
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCnYtPdODOT/t+RWgRAki0AKCDeHLFVPR89MXf9ZMQ14UaStiDqACguZsf
5Ah879KJfW73Zj2v1P+UOCI=
=3mTW
-----END PGP SIGNATURE-----



More information about the Users-l mailing list